Internal Error-graph from other PC-decimal separator issue
Internal Error-graph from other PC-decimal separator issue
Depends on MS Windows settings (usually home country preferences of PC user) decimal separator is either coma or dot. This is not handled right in MES - files from my PC (I use dot separator) are not exchangable with other users who use comma. Of course replacing in text editor all comas to dots helps, but that is not efficient solution. Could it be handled automatically or if not that there is some preference in Settings?
Re: Internal Error-graph from other PC-decimal separator iss
International language support, code pages, decimal "." vs "," separators are a real pain to code and test (I speak from limited experience )
Fiat Strada/Ritmo Abarth 130TC, Barchetta 2005 , 500X Cross Plus
Re: Internal Error-graph from other PC-decimal separator iss
This is a .NET app, so it is not a big deal...
or
... and voila! (this is not my code)
Code: Select all
public static double GetDouble(string value, double defaultValue)
{
double result;
//Try parsing in the current culture
if (!double.TryParse(value, System.Globalization.NumberStyles.Any, CultureInfo.CurrentCulture, out result) &&
//Then try in US english
!double.TryParse(value, System.Globalization.NumberStyles.Any, CultureInfo.GetCultureInfo("en-US"), out result) &&
//Then in neutral language
!double.TryParse(value, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out result))
{
result = defaultValue;
}
return result;
}
Code: Select all
Double.Parse("3,5".Replace(',', '.'), CultureInfo.InvariantCulture);