On Sun, 31 Jan 2010, james morris wrote: > On 31/1/2010, "David Nečas" <y...@physics.muni.cz> wrote: > > >> I've not had to deal with locales before, and I'm trying to understand > >> what GTK does to the locale when it initializes so I can work around it > >> and save data files as "C" locale. I've tried adding > >> setlocale(LC_NUMERIC, "C") to the start of main, and after calling > >> gtk_init, but it seems to make no difference. > > > >Generally, changing locale locally is fragile and better avoided. > > I've tried the above out by storing the current locale setting, changing > it to "C" and then restoring the locale setting once read/write is > finished and it seems to work (I installed a locale using commas as > decimal point). > > But I was told not to do this (on stackoverflow), but without the reason > why - and to use ieee754.h (which is no good considering I'm mainly > using MPFR). > > Why is store/change/restore of locale bad?
There's nothing at all wrong with it in the context you specified -- i.e. you want to ensure that floating-point values written to and read from file always use '.' as the decimal separator. I do that in my app, gretl (also for reasons of portability). It sounds like you've figured this out for yourself, but if you'd like to see how gretl does it, look at http://gretl.cvs.sourceforge.net/viewvc/gretl/gretl/lib/src/gretl_intl.c and view the latest release; the functions gretl_push_c_numeric_locale and gretl_pop_c_numeric_locale are near the top of the source. Allin Cottrell _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list