The program saves a settings file as text which contains floating point numbers of type long double
. The settings file can only be saved via the GUI (GTK2), while files can also be loaded via the command line and without bringing up the GUI.
Unfortunately, a user reports that in the files he has saved, due to his locale setting, the numbers are formatted with commas and the program refuses to load them (emitting error messages) from the command line but seems to load them when the GUI is open.
I have already asked the following question: MPFR, printf, decimal places, locales, file i/o problem which suggested using setlocale(LC_ALL, "C")
which I placed at the beginning of main
. As this did not work, I placed it after calling gtk_init_check
but again, it made no difference. (EDIT It did make a difference after I installed a few locales.)
I want the program to always use the same locale setting (or non-localized locale setting - "C") for these data files it saves, but don't want to mess up the GUI by doing so.
How?