Re: Locale definitions, dots and commas
- From: "Andrew W. Nosenko" <andrew w nosenko gmail com>
- To: "Carlos Pereira" <jose carlos pereira ist utl pt>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Locale definitions, dots and commas
- Date: Wed, 12 Mar 2008 18:31:32 +0200
On Wed, Mar 12, 2008 at 6:09 PM, Carlos Pereira
<jose carlos pereira ist utl pt> wrote:
Thanks for your answers, I realize this is not Gtk stuff,
but certainly affects every GTK app involving decimal numbers...
After setting in my .bashrc, for example (the same with portuguese,
russian, etc.):
LC_ALL=french; export LC_ALL
Everything automatically works in my GTK app, with commas instead of
dots, including exporting and importing files (involving for example the
Expat XML library).
However, a problem remains: my app is distributed with several hundreds
of example data files, ready to be imported. If these files are
dot-based, comma people cannot import them. If these files are
comma-based, dot people cannot import them... Unless I have two versions
for each file (which seems odd), or I supply a script to automatically
convert dot- to comma-based files...
If I use gtk_disable_setlocale, then dots are always used, but that does
not seem quite right... basically I am ignoring user's preference for
commas...
Is there a good solution for this? am I missing something?
What is the standard procedure in Gnome to handle this problem?
Please, consider some rewirtting of your application to do not write
locale-dependent values (floating point numbers, month abbrevs,
day-of-week abbrevs, and so on...) in the data files, or your files
will become unreadable after changing of locale (and, if I understand
correctly, you already hit this problem). Use some locale-independent
variant instead.
For case of the floating point values it could be dot-based variant as
in the "C" locale.
See g_ascii_dtostr() and/or g_ascii_formatd() for
formatting/serialization of double to string, and g_ascii_strtod()
and/or g_strtod() converting back from string to double.
--
Andrew W. Nosenko <andrew w nosenko gmail com>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]