3 ms·
When locales were invented, it was reasonable to assume that the locale would determine the character set. With the subsequent invention of Unicode that no lon
by mark-r 7y ago
When locales were invented, it was reasonable to assume that the locale would determine the character set. With the subsequent invention of Unicode that no longer needs to be the case, but code standards live forever.
- ska 7y agoIt wasn't really that reasonable as soon as it was made global. It's exactly the kind of assumption that mostly works but has dark corners from the beginning. Some imaginable version of locales was probably a good approach at the time, but that wasn't what got standardized.
- mark-r 7y agoI don't disagree, I've run into those dark corners myself. But the ease of use of globals is undeniable - there's a reason the Singleton pattern is still popular after all the ridicule it attracts.
- ska 7y agoSure, it's easy to use. But that isn't the job of standardization bodies, or the right test to use on something as low level as this. It's harder to get right, but it is exactly these sort of failures in standardization that cause the most global pain, because they wend their way through everything.
- mark-r 7y agoIn this case I don't think the locale functions were designed by committee, I think they were accepted as-is from a popular implementation. And they were implemented that way because it was the simplest most straight-forward way (I'll admit I'm just guessing now). Were they part of K&R C?
- slrz 7y agoNo, of course not.
- simias 7y ago>When locales were invented, it was reasonable to assume that the locale would determine the character set Sure, but that's not what the commit is saying. Instead it's saying that it should only determine the charset and that Unicode effectively makes locales pointless. That's absolutely not the case, there's a lot more to locales than character encoding.
- mark-r 7y agoI think we're in agreement. There are lots of aspects to a locale, and character sets are only a small part of that. Possibly the most visible part though. Unicode doesn't make character sets pointless, it only makes them deprecated. It's still useful to have a way to convert from one set to another, and it's a shame the standard library doesn't have an easy way to do that. The deficiencies of locales are visible only in hindsight.