From 678a9f4b62d4c9f06454a4c6687de357013dd8e5 Mon Sep 17 00:00:00 2001 From: CJ Yetman Date: Sat, 13 Jan 2024 15:29:29 +0100 Subject: [PATCH] add unexported `char_to_hex()` and `char_to_unicode()` utility functions --- R/char_to_.R | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 R/char_to_.R diff --git a/R/char_to_.R b/R/char_to_.R new file mode 100644 index 0000000..0eb692f --- /dev/null +++ b/R/char_to_.R @@ -0,0 +1,7 @@ +char_to_hex <- function(x) { + cat(paste(paste0("\\x", charToRaw(x)), collapse = "")) +} + +char_to_unicode <- function(x) { + cat(paste0("\\U", format(as.hexmode(utf8ToInt(x)), width = 2 * length(charToRaw(x)), upper = TRUE))) +}