Page 1 of 1
Internal Error-graph from other PC-decimal separator issue
Posted: 31 Jul 2016, 15:44
by epsonix
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
Posted: 31 Jul 2016, 16:55
by s130
International language support, code pages, decimal "." vs "," separators are a real pain to code and test (I speak from limited experience
)
Re: Internal Error-graph from other PC-decimal separator iss
Posted: 14 Sep 2016, 22:10
by tzok
This is a .NET app, so it is not a big deal...
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;
}
or
Code: Select all
Double.Parse("3,5".Replace(',', '.'), CultureInfo.InvariantCulture);
... and voila! (this is not my code)