Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the ECMAScript 6 Unicode code point escapes?

I have this Unicode character that I want to display using the new Unicode Point Escapes (i.e.e where someone uses '\u{Code Point Here}'

However, I must be doing something wrong because doing

console.log('\u{134069}');

returns:

Uncaught SyntaxError: Undefined Unicode code-point

But using

console.log('\ud842\udfb5')

returns the (correct)

𠮵

How can I use the code point escape?

like image 263
Startec Avatar asked Dec 06 '25 14:12

Startec


1 Answers

Unicode escape sequences in Javascript use hexadecimal digits to represent codepoints (which makes sense, given they are very typically represented this way). You have tried to use 134069, which, based on the surrogate pair you've supplied, is actually the decimal representation of the codepoint you're wanting to print. You'll need use hex equivalent instead, e.g. \u{20BB5} in ES6.

like image 62
nj_ Avatar answered Dec 10 '25 02:12

nj_



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!