Converts a UTF-16 encoded string to an array of integers using UTF-8 encoding.
The following byte sequences are used to represent a character. The sequence depends on the code point:
0x00000000 - 0x0000007F:
0xxxxxxx
0x00000080 - 0x000007FF:
110xxxxx 10xxxxxx
0x00000800 - 0x0000FFFF:
1110xxxx 10xxxxxx 10xxxxxx
0x00010000 - 0x001FFFFF:
11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
The x bit positions correspond to code point bits.
x
Only the shortest possible multi-byte sequence which can represent a code point is used.
UTF-8
Stack Overflow
string to convert
array of integers
var str = '☃'; var out = utf16ToUTF8Array( str ); // returns [ 226, 152, 131 ]
Converts a UTF-16 encoded string to an array of integers using UTF-8 encoding.
Notes
The following byte sequences are used to represent a character. The sequence depends on the code point:
0x00000000 - 0x0000007F:
0xxxxxxx
0x00000080 - 0x000007FF:
110xxxxx 10xxxxxx
0x00000800 - 0x0000FFFF:
1110xxxx 10xxxxxx 10xxxxxx
0x00010000 - 0x001FFFFF:
11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
The
x
bit positions correspond to code point bits.Only the shortest possible multi-byte sequence which can represent a code point is used.
UTF-8
Stack Overflow