3 ms·
-1 is not a valid Unicode code point. "All 1s" is not adequately defined without saying how many 1s – and Unicode does not specify a maximum bit width. Even i
by colanderman 15y ago
-1 is not a valid Unicode code point. "All 1s" is not adequately defined without saying how many 1s – and Unicode does not specify a maximum bit width. Even if you said "the maximum Unicode code point", that is not all 1s – it is 0x10FFFF.
- erichocean 15y agoThat'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.