Closed littlewhitecloud closed 1 year ago
These functions have surprising gotchas that users should be aware of:
setlocale(LC_ALL, "")
or similar while others don't. The setlocale()
call could also be hidden inside a library, e.g. GTK calls it. So with these functions, you can write code that works in project X on operating system Y, but does not work in a different project or on a different operating system. Or maybe your code breaks when you add a GUI written in GTK.Many other languages (e.g. Python) instead give you information about unicode characters in a way that does not depend on the current locale. I'm not yet ready to decide what's the best approach for Jou.
These functions have surprising gotchas that users should be aware of:
- These functions use the current locale, which is os-dependent, and also some projects call
setlocale(LC_ALL, "")
or similar while others don't. Thesetlocale()
call could also be hidden inside a library, e.g. GTK calls it. So with these functions, you can write code that works in project X on operating system Y, but does not work in a different project or on a different operating system. Or maybe your code breaks when you add a GUI written in GTK.- They assume that one character fits in one byte (which in UTF-8 text is only true for ASCII characters).
- When these functions don't work as expected, you only notice it with non-ASCII strings. Programmers tend to test their code only with ASCII strings.
Many other languages (e.g. Python) instead give you information about unicode characters in a way that does not depend on the current locale. I'm not yet ready to decide what's the best approach for Jou.
Think jou should not depend on setlocale.
Improve stdlib and fix #376