Skip to content

Commit

Permalink
Update char_to_.R
Browse files Browse the repository at this point in the history
  • Loading branch information
cjyetman authored Jan 17, 2024
1 parent 7590f7d commit 545640c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/char_to_.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# characters using hex or unicode R escape strings

char_to_hex <- function(x) {
cat(paste(paste0("\\x", charToRaw(x)), collapse = ""))
cat(paste0("\"", 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)))
cat(paste0("\"\\U", format(as.hexmode(utf8ToInt(x)), width = 8, upper = TRUE), "\""))
}

0 comments on commit 545640c

Please sign in to comment.