In Python 3, to convert a string to sequence of bytes, one uses String.encode(ENCODING)
where ENCODING
is the name of the encoding to use. If I have a character in my string that has a code point greater than 255, then it will still be converted to an array of bytes. This is useful if one needs to operate on the stringfor something like a demo of a cipher. The text can reconstructed by using ByteArray.decode(ENCODING)
.
I haven't seen anything similar for JavaScript. There is String.charCodeAt()
, but this would convert a character like Ā
to 256
. That's not what I want.