2 ms·
An important subtlety: JavaScript doesn’t use UTF-16 for its strings; it uses UCS-2 code units. But internally, JavaScript engines can use whatever encoding th
by chrismorgan 9y ago
An important subtlety: JavaScript doesn’t use UTF-16 for its strings; it uses UCS-2 code units.
But internally, JavaScript engines can use whatever encoding they like, though most use UCS-2 most of the time. (Servo, for example, represents documents in WTF-8 rather than the conventional UCS-2. This is good for memory efficiency and certain other things, though bad for arbitrary indexing which is rare.)
Python 2 is in the same boat concerning internal representation (it will use UTF-16 much of the time), but it doesn’t expose any UTF-16ness in the API.