SonyWWS / ATF

Authoring Tools Framework (ATF) is a set of C#/.NET components for making tools on Windows. ATF has been in continuous development in Sony Computer Entertainment's (SCE) Worldwide Studios central tools group since early 2005. ATF has been used by most SCE first party studios to make many custom tools such as Naughty Dog’s level editor and shader editor for The Last of Us, Guerrilla Games’ sequence editor for Killzone games (including the Killzone: Shadow Fall PS4 launch title), an animation blending tool at Santa Monica Studio, a level editor at Bend Studio, a visual state machine editor for Quantic Dream, sound editing tools, and many others.
Apache License 2.0
1.89k stars 262 forks source link

CultureInfo.CurrentCulture in number converter causes problems in some countries #5

Closed fuleshu closed 10 years ago

fuleshu commented 10 years ago

In some countries, like Germany, the official separator for numbers is comma and not a dot, e.g. we write "3,7" instead of "3.7". Unfortunately in C# the float or double to string converter takes this into account if you use "CultureInfo.CurrentCulture". The result is, that in Germany you can only enter numbers with comma and the data files are written with comma. By that the data files become not exchangeable between computers with different culture settings. Furthermore, even though the official number separator in Germany is a comma, we still use the international dot in computer science. To avoid this problem, C# has the following culture info setting: "CultureInfo.InvariantCulture" If you exchange "CultureInfo.CurrentCulture" with "CultureInfo.InvariantCulture" the number separator will always be a dot. Therefore I suppose that in the entire framework you change this at every function where a number conversion is made. This way the framework will work in countries like Germany as expected.

Ron2 commented 10 years ago

Thank you for the detailed bug report. To be clear, do you think that our user interfaces should accept user input and report results using CultureInfo.InvariantCulture? I would think that GUIs should use the CurrentCulture and that everything else, like file I/O, should use InvariantCulture.

A work-around might be that in Windows, in Control Panel -> Region and Language -> Formats, you could customize the date settings. And in "Additional settings", you could customize the decimal and digit grouping symbols. Would that work for you?

We do have clients in France, Netherlands, and the UK, and they apparently haven't run into this problem in the last few years. We did get a report about this issue in October of 2010, and we thought we fixed it, but that was a while ago, and it's easy to make this kind of mistake and not notice it.

We'll do some investigations. We have to be careful to not break existing clients.

Thanks again.

fuleshu commented 10 years ago

Thanks for the fast reply. You are right - I jumped to a wrong conclusion when reading the code, I thought the number converter would also be used for writing. I checked again, the output file uses "dots" for float numbers correctly.

However, I still think it should be possible to use "dots" for floats also in the gui. When working with floats in technical applications, we often use the "dots". For us using "comma" for float feels awkward and confusing. All our game tools used "dot" so far.

But, I cannot speak for other developers, perhaps some prefer it the culture "correct" way. I think it should be up to the developer to decide which one they prefer. Perhaps using a compiler define? Or give the converter and input controls an option? Changing the format in the Windows settings is no solution, as we only want the float numbers to be displayed with dots, not to change other localization settings like date or currency.

I still found a problem with this in your library which are typical to occur. In the "Grid Property Editor" a vector (float array) is displayed with a comma as field separator. With German local settings a vector (1.7, 1.5, 1.1) is now displayed as "1,7,1,5,1,1". You can easily reproduce this with the DomTreeEditor Sample.

Well, your library is really great, and as it is open source, I just changed it to how I prefer it. So it is no big issue for me.

Ron2 commented 10 years ago

I addressed this problem and some related ones: "In the "Grid Property Editor" a vector (float array) is displayed with a comma as field separator. With German local settings a vector (1.7, 1.5, 1.1) is now displayed as "1,7,1,5,1,1". You can easily reproduce this with the DomTreeEditor Sample." Thanks again for reporting the problem.