Diary
Previous: 2026-11, 2026-10, 2026-09
2026-12-03
Goddamn, I'm a real retard.
Here's why.
Although it's not defined what exactly encoding char32_t type in C is for, all functions from uchar.h
operate either with UTF-16 or UTF-32. I'm not interested in UTF-16 because it's actually a variable length
encoding thanks to surrogate pairs, so I use only UTF-32.
There's an encoding named UCS-4 which is 32-bit and which allows any value. But UTF-32 has stricter semantic: values cannot be greater than 0x10FFFF, the maximal value for codepoint as defined by Unicode standard.
That only needs three (yes, three) bytes.
Not four.
Not four as in GNU libstring. Not four as in char32_t.
Which means 25% of memory is wasted.
Which means my decision to get rid of 3-byte char size (for simplicity, yeah) was a silly mistake.
Still, I have to handle 4-byte char size because of U string literals in C.
I heard there were some architectures with 24 bit word size. Ideal for Unicode, I guess. Where are they now?