Coverting unicode codeepoint format
问题 Let's say that I have a character string containing bytes representing an emoji: string <- "This is a test. U+1F600" How can I transform it into string <- "This is a test. \U0001F600" So that I can render it as utf8_print("This is a test \U0001F600") [1] "This is a test 😀" 回答1: This is kind of a hack, but it works for your case: string <- c("This is a test. U+1F600", "Another test") # change U+XXXXYYYY to \UXXXXYYYY, quote and encode special characters expr <- gsub("U[+]([0-9A-Fa-f]{1,8})",