Skip to content
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

Wrong conversion depending on CulturalInfo #43

Closed
Kyrw opened this issue Apr 21, 2020 · 3 comments
Closed

Wrong conversion depending on CulturalInfo #43

Kyrw opened this issue Apr 21, 2020 · 3 comments

Comments

@Kyrw
Copy link

Kyrw commented Apr 21, 2020

On different machines numbers are being converted in different formats.

the number 26.643470764160158 (using float conversion), on my machine is serialized as 26.64347
but on another machine it was serialized as 2.6xxxE+16. This wouldnt be a problem but when converting back, it ingores the notation, returning 2.6xxx.

To fix this i needed to use
System.Globalization.CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture;

System.Globalization.CultureInfo.DefaultThreadCurrentUICulture** = System.Globalization.CultureInfo.InvariantCulture;

You can add this on JSONObject class, or on each method of System.Convert, call for CultureInfo.InvariantCulture as the second parameter.

Sorry for the rushed post, I'm in a hurry on my project, but wanted to at least let you guys know.
Regards

@zadinvit
Copy link

zadinvit commented Mar 17, 2021

I had same problem, my program parse "0.05" as null, but only on some devices, i fix this problem with added System.Globalization.CultureInfo.InvariantCulture to convert functions.

Example

n = System.Convert.ToSingle(str,System.Globalization.CultureInfo.InvariantCulture);

@derwaldgeist
Copy link

Same problem here. I fell into this trap when I switched from the Mac Editor to the Windows Editor, where the culture is actually been used.

@mtschoen
Copy link
Owner

mtschoen commented Jan 2, 2022

This seems to only be an issue with the Asset Store version. It was fixed on GitHub a while ago. I've made a bunch of updates and double-checked that we're using CultureInfo. I'll be updating AssetStore shortly.

@mtschoen mtschoen closed this as completed Jan 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants