Re:I'm Not a Fan of Strlcpy(3)
by MathMonkeyMan on Monday July 15, 2024 @09:30AM
(#40967743)
The null code point? That would be pedantic even by my standards.
[ Parent
| on HN ]
Look I had to include it or someone is going to do a whole pedantic comment about how C can’t actually represent UTF-8 correctly
You could have just said it rather than going through this smug "I know something you don't know!" song and dance.
Also, by this rationale, NO string is ever safe in C, because pretty much every encoding technically supports codepoint 0 (even though you take your life into your hands should you ever use it). This is not a useful discussion.
I mean strings that don't use that codepoint are fine, and that's most strings as I mentioned above.
Actually, by just alluding to the bug without saying it explicitly, you managed to both be pedantic and not avoid the discussion.
This is not meant as a personal attack; I just want to point out how it looks on a casual reading :)
Well, I'm not perfect ;)
By that metric, C can't represent ASCII correctly either, because there's no particular reason you couldn't have a NUL character somewhere inside a string.
Indeed it can't. Many developers were bitten by this, and still are; plenty of critical bugs and security vulnerabilities rely on this quirk too.
Technically, C can. It's just C strings that are limited.