On Wednesday 12 March 2008 17:31:32 Andrew W. Nosenko wrote:
> On Wed, Mar 12, 2008 at 6:09 PM, Carlos Pereira
> <[EMAIL PROTECTED]> 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.

DECIMAL[(M[,D])] [UNSIGNED] [ZEROFILL]

For MySQL 5.0.3 and above:

A packed “exact” fixed-point number. M is the total number of digits (the 
precision) and D is the number of digits after the decimal point (the scale). 
The decimal point and (for negative numbers) the ‘-’ sign are not counted in M. 
If D is 0, values have no decimal point or fractional part. The maximum number 
of digits (M) for DECIMAL is 65 (64 from 5.0.3 to 5.0.5). The maximum number of 
supported decimals (D) is 30. If D is omitted, the default is 0. If M is 
omitted, the default is 10.

UNSIGNED, if specified, disallows negative values.

All basic calculations (+, -, *, /) with DECIMAL columns are done with a 
precision of 65 digits. 


so for example 123456,01 if you use as standard value DECIMAL(10,2) would be 
12345601.
This value could then be converted at runtime when imported to the correct 
decimal separator.

val = atoi("1234501") / 100;

Just an idea,
Tito

PS: sorry for the double post....
_______________________________________________
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