3 ms·
UTF-8 encoding works like so: 0xxxxxxx 110xxxxx 10xxxxxx 1110xxxx 10xxxxxx 10xxxxxx 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx ...where the "x" bits encode t
by _moof 5y ago
UTF-8 encoding works like so:
0xxxxxxx
110xxxxx 10xxxxxx
1110xxxx 10xxxxxx 10xxxxxx
11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
...where the "x" bits encode the code point. So if you're halfway through a four-byte sequence and see a byte like 0xxxxxxx, you know something's wrong.