4 ms·
utf-8 has an elegance that utf-16 lacks: utf-8 decode switch (std::countl_one(unit)) { case 0: /* one unit */ break;
by SaddledBounding 4y ago
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;
}
- Mikhail_Edoshin 4y agoOh, 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.
- bergesenha 4y agoI’m happy every time I see c++20 in the wild