GnuplotCSharp
GnuplotCSharp copied to clipboard
problem with ToString() in russian
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 ( ',', '.').
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?
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
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
but what faster, ToString().Replace ( ',', '.') or ToString(CultureInfo.InvariantCulture)
ToString() is equivalent to ToString(CultureInfo.CurrentCulture) So using ToString(CultureInfo.InvariantCulture) instead of ToString().Replace ( ',', '.') will be faster and consistent.