From wxString methods, this one looks like our friend. Edwin, is it available 
in wx2.8 ? 

Conversion to numbers

The string provides functions for conversion to signed and unsigned integer and 
floating point numbers.

All functions take a pointer to the variable to put the numeric value in and 
return true if the entire string could be converted to a number. Notice if 
there is a valid number in the beginning of the string, it is returned in the 
output parameter even if the function returns false because there is more text 
following it.

bool    ToDouble (double *val) const
        Attempts to convert the string to a floating point number. 
 
bool    ToCDouble (double *val) const                                         
<-----------
        Variant of ToDouble() always working in "C" locale. 

Miguel Angel Ajo
http://www.nbee.es
+34911407752
skype: ajoajoajo

On 15/03/2013, at 12:22, Miguel Angel Ajo Pelayo <[email protected]> wrote:

> sprintf and others will render also using the LC_NUMERIC, or locale set in 
> program, yet looking
> how to workaround this...
> 
> http://www.stroustrup.com/3rd_loc.pdf
> 
> Miguel Angel Ajo
> http://www.nbee.es
> +34911407752
> skype: ajoajoajo
> 
> On 15/03/2013, at 11:30, Miguel Angel Ajo Pelayo <[email protected]> wrote:
> 
>> Thanks edwin, I will try to fix it this night with a 2.8 compatible solution,
>> 
>> Also thanks a lot for the suggestion,
>> 
>> Anyway, I don't like changing the locale back and forth, I know the risk
>> is minimal, but in a multithreading UI environment It could break anything
>> running/displaying/printing elsewhere.
>> 
>> So, for the moment I will stay with a replace solution, or use a system 
>> printf
>> ignoring the locale settings. I will check for that other option on the 
>> change.
>> 
>> My solution could break if we go into a locale that sets numbers like 
>> 1.000.000,1111
>> 
>> 
>> I'll change that in a few minutes and re-commit.
>> 
>> 
>> 
>> Miguel Angel Ajo
>> http://www.nbee.es
>> +34911407752
>> skype: ajoajoajo
>> 
>> On 15/03/2013, at 11:25, Edwin van den Oetelaar 
>> <[email protected]> wrote:
>> 
>>> Hello Miguel,
>>> 
>>> My WX is 2.8
>>> 
>>> Your WX is 2.9 I guess
>>> http://wiki.wxwidgets.org/Converting_everything_to_and_from_wxString
>>> 
>>> I think there should be a cleaner way to handle this kind of thing.
>>> (comma/dot in floating point)
>>> Would it be possible to set LC_NUMERIC someway?
>>> 
>>> char prvlocale[255];
>>> strcpy( prvlocale, wxSetlocale(LC_NUMERIC, NULL) );
>>> const char *oldLocale = wxSetlocale(LC_NUMERIC, "C");
>>> 
>>> /* DO STUFF HERE */
>>> 
>>> if ( !oldLocale )
>>> {
>>> /* the current locale was not changed; no need to */
>>> /* restore the previous one... */
>>> } else {
>>> /* restore the original locale */
>>> wxSetlocale(LC_NUMERIC, prvlocale);
>>> }
>>> 
>>> /home/oetelaar/kicad_dev/kicad/pcbnew/footprint_wizard.cpp: In member
>>> function ‘void FOOTPRINT_WIZARD_FRAME::ParametersUpdated(wxGridEvent&)’:
>>> /home/oetelaar/kicad_dev/kicad/pcbnew/footprint_wizard.cpp:190: error:
>>> no matching function for call to ‘wxString::Replace(const char [2],
>>> const char [2])’
>>> /usr/include/wx-2.8/wx/string.h:1173: note: candidates are: size_t
>>> wxString::Replace(const wxChar*, const wxChar*, bool)
>>> make[2]: *** [pcbnew/CMakeFiles/_pcbnew.dir/footprint_wizard.cpp.o] Error 1
>>> make[1]: *** [pcbnew/CMakeFiles/_pcbnew.dir/all] Error 2
>> 
> 

_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp

Reply via email to