Internal Error-graph from other PC-decimal separator issue

Report any bugs found in multiecuscan
Post Reply
epsonix
Posts: 10
Joined: 06 Mar 2016, 12:03

Internal Error-graph from other PC-decimal separator issue

Post by epsonix » 31 Jul 2016, 15:44

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?

s130
Posts: 945
Joined: 20 Jan 2010, 10:07
Location: Wrexham, North Wales

Re: Internal Error-graph from other PC-decimal separator iss

Post by s130 » 31 Jul 2016, 16:55

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

tzok
Posts: 172
Joined: 11 Mar 2010, 21:45
Location: Bielsko-Biala, Poland
Contact:

Re: Internal Error-graph from other PC-decimal separator iss

Post by tzok » 14 Sep 2016, 22:10

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)

Post Reply