5 ms·
As awesome as these algorithms are, I can never imagine use case. Any time I need to turn something into uppercase or lowercase, it's user's input or something
by Tringi 2y ago
As awesome as these algorithms are, I can never imagine use case.
Any time I need to turn something into uppercase or lowercase, it's user's input or something Unicode. Which can be in any random language, so all the crazy Unicode casing rules apply.
I mean, Czech could work by canonical Unicode decomposition and then re-composition afer case change ...but the input can be in Russian or Greek. I can't imagine accelerating that, or rather taking into account all the ranges.
- fanf2 2y agoThere are lots of protocols that are ASCII case-insensitive, such as SMTP, IMAP, HTTP, DNS, … so this kind of code is common in the hot path of lots of networking software.
- Tringi 2y agoAh, yeah, that's true.
- jimmies 2y agoIf your input is Russian mixed with English, it might still be actually faster to do a first pass to process all the ASCII English range first with the aforementioned techniques, then do Russian later in the second pass: imagine you’ll have way less if branches to do.