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

problem with ToString() in russian #2

Open
alexgubanow opened this issue Nov 15, 2016 · 5 comments
Open

problem with ToString() in russian #2

alexgubanow opened this issue Nov 15, 2016 · 5 comments

Comments

@alexgubanow
Copy link

In the Russian localization of the character ',' is a decimal separator, and when you call ToString.() method, the line turns like "0,01", and is not correct.
The solution is simple, add .Replace ( ',', '.').

@AwokeKnowing
Copy link
Owner

thanks. Someone else had this same issue in a different country. can you give some examples of the usage? are the , characters in the data, or in function parameters or results, or where?

@alexgubanow
Copy link
Author

sorry, but i am don't use anymore GNUplot. but i think it was something like that:
stream.WriteLine(y[i].ToString()); //source
stream.WriteLine(y[i].ToString().Replace ( ',', '.'));//modifed

@ToniaDemchuk
Copy link

The problem is when you have some decimal numbers like 0.1 the .ToString() will produce different results depending on current culture
stream.WriteLine(y[i].ToString()); //"0.1" with dot in en-US
stream.WriteLine(y[i].ToString()); //"0,1" with comma in ru-RU

It's better to use CultureInfo.InvariantCulture in thie case, e.g.:
stream.WriteLine(y[i].ToString(CultureInfo.InvariantCulture)); // "0.1" with dot in all cultures

@alexgubanow
Copy link
Author

but what faster, ToString().Replace ( ',', '.') or ToString(CultureInfo.InvariantCulture)

@ToniaDemchuk
Copy link

ToString() is equivalent to ToString(CultureInfo.CurrentCulture)
So using ToString(CultureInfo.InvariantCulture) instead of ToString().Replace ( ',', '.') will be faster and consistent.

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

3 participants