65535 different code points. A subset of these strings is represented by UTF-16 strings containing only ASCII characters (i.e., characters whose code point does not exceed
127). For instance, the string
"Hello world!" belongs to the ASCII subset, while the string
"ÀÈÌÒÙ" does not. A binary string is a concept similar to the ASCII subset, but instead of limiting the range to
127, it allows code points until
btoa(): invoking it on a string that contains codepoints greater than
255 will cause a
Character Out Of Range error.
The reason that brought to use UTF-16 code units as placeholders for
In the past, this had to be simulated by treating the raw data as a string and using the
charCodeAt() method to read the bytes from the data buffer (i.e., using binary strings). However, this is slow and error-prone, due to the need for multiple conversions (especially if the binary data is not actually byte-format data, but, for example, 32-bit integers or floats).
StringView Non native constructor is one level above typed arrays and provides a C-like interface for strings.