3 ms·
A UTF-8 string can perfectly well contain the character U+0000, which will be encoded as a null byte 0x00. So just "leaving out the null bytes" amounts to chan
by jfk13 6y ago
A UTF-8 string can perfectly well contain the character U+0000, which will be encoded as a null byte 0x00.
So just "leaving out the null bytes" amounts to changing the string to a different string. Sometimes that may be what you want, but it doesn't sound like a good idea in general.
- tremon 6y agoThat was a bit of a rabbit hole. As it turns out, neither the ASCII nul character nor its Unicode equivalent have the semantic meaning "end of stream". ASCII does have control characters for "end of stream", in fact multiple: 0x03 End Of Text, 0x04 End Of Transmission, and 0x17 End Transmission Block. But 0x00 was never intended to be an end marker of any kind. It's really only the C standard that (ab)uses NUL as an end-of-string marker. So yes, after consideration, I'm starting to agree with you. U+0000 is a valid character and should be allowed in text fields.