News for hackers. Stuff that matters.
Re:JavaScript’s internal character encoding: UCS-2 or UTF-16? by yonran on Friday January 20, 2012 @12:47PM (#3490341)
This means that for applications that want to store binary data as efficiently as possible in localStorage (e.g. Offline Wikipedia https://news.ycombinator.com/item?id=3409512), you can pack two bytes into each string character. ECMAScript strings are just arrays of 16-bit unsigned integers (e.g., '\ud800' is a valid JS string but is not valid UTF-16).
Re:JavaScript’s internal character encoding: UCS-2 or UTF-16? by mathias on Friday January 20, 2012 @12:58PM (#3490398)
It’s worth pointing out that `'\ud800'` is not valid UCS-2 either, since UCS-2 technically doesn’t allow surrogate characters.

JavaScript strings are like UCS-2, except that they allow surrogate characters.