1

I have some unicode character that is stored as "<U+9577><U+6D32>". Is it possible to convert it into "\u9577\u6D32"?

Thanks!

pe-perry
  • 2,591
  • 2
  • 22
  • 33

1 Answers1

4

You could use

as.character(parse(text=shQuote(gsub("<U\\+([A-Z0-9]+)>", "\\\\u\\1", "<U+9577><U+6D32>"))))

(via)

Community
  • 1
  • 1
lukeA
  • 53,097
  • 5
  • 97
  • 100