JavaScript strings are UTF-16 encoded strings. This means that each code unit requires two bytes of memory and is able to represent 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 255
. Its purpose however is not to represent characters, but binary data. The size of the data so represented is twice as big as it would be in normal binary format, however this will not be visible to the final user, since the length of JavaScript strings is calculated using two bytes as the unit.
Binary st