Re: Posix(?) on numeric entry



On Tue, Feb 15, 2005 at 10:37:48AM +0100, antongiulio wrote:
> my app writes a "double" value on a gtk_entry with this code:
> 
> gchar *buffer;
> double value = 2.59787;
> 
> buffer = g_strdup_printf("%g", value);
> gtk_entry_set_text (GTK_ENTRY (value_entry), buffer);
> g_free (buffer);
> 
> *****************
> 
> this value appears like: 2,59787 where ',' replaces a '.'
> I suppose it's related to *_NL locale replaces posix locale.
> How can I replace ',' with dot notation?

Don't.  If user expressed his wish to format numbers with
a decimal comma instead of point by setting LC_NUMERIC, you
should not enforce decimal point.  And other functions like
scanf() use/expect decimal comma too in such a locale
anyway.

If you didn't format the numbers for user interface, but to
serialize them to some data file for example, you could use
g_ascii_dtostr() or g_ascii_formatd(), but for user
interface this would be arrogant.

Yeti


--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]