← Back to team overview

kicad-developers team mailing list archive

Re: Locale fix in KiCAD is not working (breaks my build)


JP, it's a problem to pull a dependency on wxwidgets 2.9.x? and use the  CDouble methods from
wxString? ,

It seems to work here, and LOCALE_IO seems dangerous regarding threading.

This is the FromCDouble implementation, they used a Replace, as my original solution :-)

wxString wxString::FromCDouble(double val, int precision)
    wxCHECK_MSG( precision >= -1, wxString(), "Invalid negative precision" );

    // We assume that we can use the ostream and not wstream for numbers.
    wxSTD ostringstream os;
    if ( precision != -1 )
        os.setf(std::ios::fixed, std::ios::floatfield);

    os << val;
    return os.str();
#else // !wxUSE_STD_IOSTREAM
    // Can't use iostream locale support, fall back to the manual method
    // instead.
    wxString s = FromDouble(val, precision);
#if wxUSE_INTL
    wxString sep = wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT,
#else // !wxUSE_INTL
    // As above, this is the most common alternative value. Notice that here it
    // doesn't matter if we guess wrongly and the current separator is already
    // ".": we'll just waste a call to Replace() in this case.
    wxString sep(",");
#endif // wxUSE_INTL/!wxUSE_INTL

    s.Replace(sep, ".");
    return s;

Miguel Angel Ajo
skype: ajoajoajo

On 15/03/2013, at 12:57, Miguel Angel Ajo Pelayo <miguelangel@xxxxxxx> wrote:

> Jean Pierre, 
>   It sounds like what I need, without adding dependencies on 2.9 or 3.0 (as Edwin was pointing me privately).
>   Anyway, that cannot be a problem with threading? or it just sets locale "locally" and not App wide?
> Thanks a lot for the help,
> Miguel Angel Ajo
> http://www.nbee.es
> +34911407752
> skype: ajoajoajo
> On 15/03/2013, at 12:49, jp charras <jp.charras@xxxxxxxxxx> wrote:
>> We have this kind of issue for all I/O file functions.
>> In KiCad there is a class named LOCALE_IO to fix it
>> thee ctor switches on the "C" fp notation, and the dtor restores the current locale.
>> See for instance the line:
>> LOCALE_IO   toggle;     // toggles on, then off, the C locale.
>> in pcb_parser.cpp, line 333
>> -- 
>> Jean-Pierre CHARRAS
>> _______________________________________________
>> Mailing list: https://launchpad.net/~kicad-developers
>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~kicad-developers
>> More help   : https://help.launchpad.net/ListHelp