-
Notifications
You must be signed in to change notification settings - Fork 485
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
Writing floats is locale dependent #70
Comments
Afaik, this bug was fixed in 1.0.4. Can you please provide some more details about the platform you are using, and how you are compiling Lua CJSON? There are 2 ways of compiling floating point support:
This is documented in the manual under Built-in floating point conversion. |
I'm using the Debian package for 2.1 which doesn't use specific preprocessor arguments. I'll ask the Debian maintainer to build with USE_INTERNAL_FPCONV, but cjson still needs to support usage with a non-constant locale setting IMHO. |
Also, what about locales that don't even use "our" digits? |
While the hack to detect/adapt the decimal separator for different locales is ugly, I'm not aware of any specific locales where it doesn't work (happy to hear otherwise). Changing the locale after the program has started is typically a bad strategy. I agree it would be better to have a single implementation. However, there are tradeoffs:
It's an awkward tradeoff. I wanted Lua CJSON to just work out of the box, which means using the platform routines. The internal dtoa has advantages but must be build correctly for the platform and the codebase. If Debian wants to use the internal routines it will need to correctly set the endianness, and probably always enable/link pthreads (since it may be used in a multi-threaded application). |
Another option: Can you call |
Another option.. You could use compiler defines to autodetect the correct endianness for It might be reasonable to add something similar to CJSON as well, but it would need testing across a wide range of compilers/platforms first. |
Hi,
CJSON is not locale independent. Specifically, if the current locale wants us to encode the decimal point as a comma, as in Germany, CJSON will happily do so.
This makes the other side rather unhappy. Worse, if the problem occurs in a list it's not even recognized by the receiving parser.
Please fix!
The text was updated successfully, but these errors were encountered: