Re:How UTF-8 Works
by mark-r on Tuesday February 08, 2022 @02:02PM
(#30262876)
The only guarantee that C gives you is that sizeof char == 1, and even that's not as useful as it looks.
[ Parent
| on HN ]
Re:How UTF-8 Works
by SAI_Peregrinus on Tuesday February 08, 2022 @04:23PM
(#30264903)
It also guarantees that char is at least 8 bits.
And POSIX does guarantees that CHAR_BIT == 8 so in practice this is only a concern on embedded platform where you are only dealing with "C-ish" anyway.
Re:How UTF-8 Works
by SAI_Peregrinus on Wednesday February 09, 2022 @06:45PM
(#30280483)
Or any other non-POSIX system. I'm not sure what Windows guarantees, but it's definitely not a POSIX system.
How many non-embedded non-POSIX systems do you know? Windows also guarantees CHAR_BIT == 8 and since most software is first written for Windows or POSIX there is plenty of software that assumes that CHAR_BIT == 8. That means that anything that will want to run general software needs to also ensure CHAR_BIT == 8 - not to mention all the algorithms and data formats designed around you being able to efficiently access octets. The only platforms that can get away with CHAR_BIT != 8 are precisely those that have software specially written for them, i.e. embedded systems.