Unicode value \uXXXX to Character in Javascript

The .fromCharCode() function takes a number, not a string. You can’t put together a string like that and expect the parser to do what you think it’ll do; that’s just not the way the language works.

You could ammend your code to make a string (without the ‘\u’) from your hex number, and call

var n = parseInt(hexString, 16);

to get the value. Then you could call .fromCharCode() with that value.

Leave a Comment