Re:The sad history of Unicode printf-style format specifiers...
by SaddledBounding on Thursday December 01, 2022 @10:30AM
(#33817546)
utf-8 has an elegance that utf-16 lacks:
utf-8 decode
switch (std::countl_one(unit)) {
case 0:
/* one unit */
break;
case 2:
/* two units */
break;
case 3:
/* three units */
break;
case 4:
/* four units */
break;
default:
/* not code point boundary */
break;
}
Re:The sad history of Unicode printf-style format specifiers...
by Mikhail_Edoshin on Friday December 02, 2022 @12:01AM
(#33826992)
Oh, thanks, this one is good. Must be rather fast on major platforms. But with this optimization UTF-8 still remains harder computationally than UTF-16.
Re:The sad history of Unicode printf-style format specifiers...
by bergesenha on Friday December 02, 2022 @02:18AM
(#33827807)
Iām happy every time I see c++20 in the wild
Things get even more complex when we are to read an untrusted string. In UTF-8 we have five byte types, invalid bytes, conditionally invalid bytes, and must recognize surrogates (as errors). In UTF-16 all 16-bit units are valid and there are only three unit types: character or surrogate, high or low. I once wrote a decoder for UTF-8/16 and here's my stats: