3 ms·
This makes me wonder is a there a programming language which has separate data types for locale aware and locale independent strings. I know that rust has OsStr
by Karliss 1y ago
This makes me wonder is a there a programming language which has separate data types for locale aware and locale independent strings. I know that rust has OsString but that's a slightly different usecase.
Problem with the current widely used approach of having global application wide locale setting is that most applications contain mix of User facing strings and technical code interacting with file formats or remote APIs. Doesn't matter if you set it to current language (or just let operating system set it) or force it to language independent locale, sooner or later something is going to break.
If you are lucky a programming language might provide some locale independent string functions, but using them is often clunky and and unlikely to be done consistently across whole code base and all the third party libraries. It's easier to do things correctly if you are forced to declare the intention from the start and any mixing of different context requires an explicit conversion.
- sam_lowry_ 1y agoС
- pjc50 1y agoC doesn't have a string data type, let alone a locale-aware one. No, the Microsoft LPCWSTR madness doesn't count.
- deleted 1y ago[deleted]
- NooneAtAll3 1y agobecause C doesn't make types aware, but functions? https://en.cppreference.com/w/c/string/multibyte https://en.cppreference.com/w/c/string/multibyte
- pjc50 1y agoYes. And the C type system isn't rich enough to represent "do not pass this type of string into this function".
- dhosek 1y agoRust also has an ASCII-specific casefolding function.
- GoblinSlayer 1y agoAFAIK ruby string has embedded charset.