Reputation: 2621
I have some unicode character that is stored as "<U+9577><U+6D32>". Is it possible to convert it into "\u9577\u6D32"?
"<U+9577><U+6D32>"
"\u9577\u6D32"
Thanks!
Upvotes: 1
Views: 1805
Reputation: 54237
You could use
as.character(parse(text=shQuote(gsub("<U\\+([A-Z0-9]+)>", "\\\\u\\1", "<U+9577><U+6D32>"))))
(via)
Upvotes: 4