0

I have a data with unicode from server side, just like below.

data = "text\\u0041text"

I need to display this data by inserting html, use the code below.

document.body.innerHTML = "<div>" + data + "</div>";

And the result I expected is showing unicode charactor on the page, but what I get is a unicode string (\\u0041).

the way I tried is using str.replace, but I can't replace the escape character(\\).

So my question is How can I convert unicode in a string to unicode string.

Someone can help please?

Kevin Chen
  • 122
  • 8
  • 1
    Don't be mislead by the fact the question there was asking about data in an URL, all you need is `document.body.innerHTML = "
    " + JSON.parse( '"' + data + '"' ); + "
    "`
    – Kaiido Aug 09 '21 at 02:43

0 Answers0