es6-features icon indicating copy to clipboard operation
es6-features copied to clipboard

ES6 astral-plane unicode support

Open webbedspace opened this issue 9 years ago • 0 comments

"Astral plane" characters (those whose code point value >= 0x10000) are supported in ES6 in the following ways:

  • Iteration over strings correctly produces the code point - console.log(...'a😬c') logs "a" "😬" "c", whereas var str = 'a😬c'; for (var i = 0; i < str.length; i++) { console.log(str[i]) } logs "a" "�" "�" "c".
  • In that vein, [...'a😬c'].length is the correct value of 3, rather than 'a😬c'.length's incorrect value of 4.
  • String.codePointAt() lets you receive the correct code point - 'a😬c'.codePointAt(1) is '😬', but 'a😬c'[1] is '�'.

webbedspace avatar May 03 '15 06:05 webbedspace