-
Notifications
You must be signed in to change notification settings - Fork 119
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
strtod and locale #820
Comments
strtod is locale-sensitive and yes, JS is locale-insensitive, so that's a problem. Maybe not a huge problem but still. Libraries as a rule shouldn't touch setlocale() and replacing strtod() with a homegrown thing is not trivial (musl libc's strtod is over 500 lines) so I don't know if this is actually something we'll want to fix. |
Looking at the old PR that switched to the Bellard's version, it seems we indeed caught the problem with French locale and doubles:
So it seems like a rather big-ish problem. |
Relying on |
I have a question about how JS deals with doubles and locale.
From StackOverflow it seems that it doesn't respect the locale at all. Is this true?
Anyway, QuickJS uses strtod which is locale-aware
We've patched QuickJS with a "safe_strtod" that enforces "C" locale to avoid issues on different platforms.
However I am wondering if this should got to upstream and it it is, in which form? Maybe simply re-implement locale-unaware strtod without the need to call dreaded "locale" functions (surely there are multiple implementations on the web)
The text was updated successfully, but these errors were encountered: