-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
make parsing float literals locale-independent #5928
Comments
We do call setlocale, but libraries can annoyingly override it. |
it's harder to say what the functions in base should do. on the one hand, when parsing code, the author of the code expects to need to use C-style notation "1.0", esp. since "1,0" already means something different on the other hand, GUI libraries like Gtk, are probably right to try to conform to the user's locale preference setting (I don't actually know how strongly users feel about this). the functions in base may fall into this category. we may need two functions. |
yes I vote for making these also locale-independent. Maybe provide special versions that are locale-dependent. Or a keyword argument. |
I find it quite annoying when technical GUIs respect the locale settings but this is because I as a programmer have been running into issues several times. But when writing a GUI in Juliaand when wanting But in general we should look into how others (Java, Python, ...) have solved this (or not solved this...) |
I was looking up python just now. I don't think it is the greatest example. They mostly defer the work to a Java seems like it has roughly the same behavior as python. PHP, Javascript seem like they may have roughly the same behavior as C. If non-US users have become comfortable with either format anyways (and don't find it inconsiderate), then I vote for making numerical parsing consistently locale-independent, unless the user specifically asks for it (probably by directly calling functions from a |
Agree. There are probably ISO standard formats anyway.
|
sounds like a plan. And as Julia calls Good that this is tagged with the |
I agree, I've always hated systems that switch parsing on me because of my locale settings. |
I'm pretty sure that's a quorum of people from other countries who hate this feature, despite its good intentions. It does seem like pure insanity to me. |
Well, I know that Swedish programmers quite generally hate the comma as a |
Germans too. I have been running into that trap in C several times when reading/writing ini files. But although I hate it as a programmer, there are very good reasons to have it in GUIs and websites. So we should be open minded to the problem of locale formatting. The big issue with |
@JeffBezanson @vtjnash:
I would put this into a file |
Ok I think the I will later prepare a PR. My environoment is OSX. The windows implementation will have to be tested by someone having a build environoment. |
Living in a country where The same applies to formatting decimal numbers: UI printing (e.g. the REPL) should adapt to the user locale but exporting functions should always use |
Great, let's try this. Thanks @tknopp . |
I tried to do this using |
@vtjnash: I have |
In non-US locales, floating point numbers are written with a comma (e.g. "1,0" instead of "1.0").
strtod
can be reconfigured to accept this alternative input, which breaks parsingref JuliaGraphics/Gtk.jl#69
@JeffBezanson per chat messages, suggestion is to pull this function from FreeBSD and remove the locale bits we don't want
The text was updated successfully, but these errors were encountered: