3 ms·
That's the entire point of choosing -1 as an "end of sequence" marker for a UTF-8 string when the length is not known up front. A byte containing all 1s is not
by erichocean 15y ago
That's the entire point of choosing -1 as an "end of sequence" marker for a UTF-8 string when the length is not known up front.
A byte containing all 1s is not valid in any Unicode encoding, so if one appears, you'd know you had hit the end of the string.
- adobriyan 15y agoThis doesn't work well with handling ill-formed sequences. The length is of course known upfront if not of the whole string but at least of the individual small substring.
- colanderman 15y agoOK, I thought you meant a code point containing all 1s. Thanks for clearing that up.