Re: Locale definitions, dots and commas
- From: zz excite it
- To: gtk-app-devel-list gnome org
- Subject: Re: Locale definitions, dots and commas
- Date: Wed, 12 Mar 2008 20:06:22 +0100
On Wednesday 12 March 2008 17:31:32 Andrew W. Nosenko wrote:
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.
Maybe you can use some char based format as DECIMAL in mysql.
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]