Why we can't process Emoji anymore
11–20 of 162 posts
Re: Why we can't process Emoji anymore
#12TLDR: node sucks
TLDR: The V8 engine can't (supposedly) encode Unicode codepoints that are over 16-bits in length, because it uses the UCS-2 encoding.
Edit: v8 in general is pretty cool, but not supporting Unicode outside UCS-2 is pretty bad.
Re: Why we can't process Emoji anymore
#13TLDR: node sucks
It's v8's fault, and v8 does not suck.
Re: Why we can't process Emoji anymore
#14Re: Why we can't process Emoji anymore
#15Why on earth would the people who wrote V8 use UCS-2? What about alternative JS runtimes?
Re: Why we can't process Emoji anymore
#16UTF-16 is not a very good encoding. It only exists for legacy reasons. It has the same major drawback as UTF-8 (variable-length encoding) but none of the benefits (ASCII compatibility, size efficient).
Re: Why we can't process Emoji anymore
#17Re: Why we can't process Emoji anymore
#18This is why UTF-8 is great. If it works for any Unicode character it will work for them all. Surrogate pairs are rare enough that they are poorly tested. With UTF-8, if there are issues with multi-byte characters, they are obvious enough to get fixed. UTF-16 is not a very good encoding. It only exists for legacy reasons. It has the same major drawback as UTF-8 (variable-length encoding) but none of the benefits (ASCI…
Re: Why we can't process Emoji anymore
#19TL;DR:
- Javascript engines are free to internally represent strings as either UCS-2 or UTF-16. Engines that choose to go USC-2 tend to replace all glyphs outside of the BMP with the replacement char (U+FFFD). Firefox, IE, Opera, and Safari all do this (with some inconsistencies).
- However, from the point of view of the actual JS code that gets executed, strings are always UCS-2 (sort of). In UTF-16, code points outside the BMP are encoded as surrogate pairs (4 bytes). But -- if you have a Javascript string that contains such a character, it will be treated as two consecutive 2-byte characters.
var x = '𝌆';
x.length; // 2
x[0]; // \uD834
x[1]; // \uDF06
Note that if you insert said string into the DOM, it will still render correctly (you'll see a single character instead of two ?s).Re: Why we can't process Emoji anymore
#20Why on earth would the people who wrote V8 use UCS-2? What about alternative JS runtimes?
Because Unicode was sold to the world's software developers as a fixed-width encoding claiming 16 bits would be all we'd ever need.
I'm pretty sure work on V8 started after 1996.
More likely is the idea that the authors of V8 felt that UCS-2 was an acceptable speed/correctness trade-off.