On Sun, Jan 31, 2010 at 04:10:00PM +0000, james morris wrote:
> 
> A user has reported a problem with my app being unable to load a settings
> file from the command line when the program runs without a GUI.
> 
> The OPs locale uses commas as the decimal point and the programs use of
> locale changes when GTK is initialized.
> 
> However, the same file which does not load from the command line without
> a GUI will load with the GUI up.
> 
> I want these files to always be written in the "C" locale so they're
> portable across locales, but I don't want to clobber the GUI to do so.
> 
> I've read archived posts recommending to use the glib conversion
> functions, however these are limited to double precision, and the
> minimum precision my app is using is long double, as it also uses the
> MPFR library for unlimited multiple precision maths.

Look at the GLib conversion functions and write your own for MPFR types.
It is a matter of checking the locale's decimal separator and fixing the
string representation accordingly.

> 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.

Yeti

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to