▲ | jridgewell 4 days ago | |||||||
This isn't quite right. In invalid UTF8, a continuation byte can also emit a replacement char if it's the start of the byte sequence. Eg, `0b01100001 0b10000000 0b01100001` outputs 3 chars: a�a. Whether you're at the beginning of an output char depends on the last 1-3 bytes. | ||||||||
▲ | rockwotj 4 days ago | parent [-] | |||||||
> outputs 3 chars You mean codepoints or maybe grapheme clusters? Anyways yeah it’s a little more complicated but the principle of being able to truncate a string without splitting a codepoint in O(1) is still useful | ||||||||
|