0

I have a text string that includes an escape sequence like \u00f1. When I ingest in JS and try to append the string to a div, it's literally rendering \u00f1 rather than ñ.

I've tried en/decodeURIComponent and un/escape() to no avail.

Any tricks on how to get the escape sequence rendering the correct UTF-8 character in JS?

P.S. The page is already encoded in UTF-8

1
  • Can you show us a complete example? Commented Apr 19, 2013 at 4:49

1 Answer 1

0

The only sane solution is to make sure HTML is properly encoded. Trying to "decode" content may easily bring cross-site-scripting (XSS) issues (incomplete attempt to fix it is likely reason why you see over-encoded text).

Otherwise you can try to decode it several times (for good measure) by using innerHTML and content properties...

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.