-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Functions that depend on the current C locale #11952
Comments
Here is a list of non-Windows functions I could find that depend on the C locale:
On Windows it has been noted that |
It is at least questionable that So for anyone else affected by this like me, fun main(argc : Int32, argv : UInt8**) : Int32
LibC.setenv("LC_ALL", "en_US.UTF-8", 1)
Crystal.main(argc, argv)
end so essentially just overwriting the users locale. |
Some libc implementations have implementations liks I suppose the best solution is to move to native implementations for locale-based algorithms. |
Another alternative is https://github.com/fastfloat/fast_float, now part of GCC and llvm-libc |
Some
LibC
funs, likestrtod
inString#to_f64?
, andsnprintf
inFloat::Printer#internal
, depend on the currently active C locale. This means some oddities could happen if a different locale is active:All programs start with the
C
C locale, but third-party shards might nonetheless change it, leading to those hard to debug scenarios. To my understanding the entire Crystal standard library should be locale-independent.Is there anything we could do here apart from reimplementing all of
LibC
's locale-dependent functions in Crystal? (There are probably other kinds of global state in the C runtime to avoid too.)The text was updated successfully, but these errors were encountered: