Problem with locales



Hello all,

I'm having a strange behaviour when retrievieng numeric values from a GtkEntry widget; somewhere into my code I set a numeric value as:

  gtk_entry_set_text (GTK_ENTRY (enThick), "3.45");

then elsewhere I retrieve such a value with:

G_CONST_RETURN gchar * gcPdi;
gfloat                 thick;
[...]

  gcPdi = gtk_entry_get_text (GTK_ENTRY (enThick));
  sscanf (gcPdi, "%f", & thick);

If I inspect the variables I find: gcPdi = "3.45" and thick = 3; instead with:

  gtk_entry_set_text (GTK_ENTRY (enThick), "3,45");

I find: gcPdi = "3,45" and thick = 3.45

This could be normal if we consider that current locale is it_IT euro, which has as default "," as decimal separator; what I cannot understand is how "sscanf", which is a standard C function, can follow locale rules. The second aspect of this issue is that the same application doesn't show this behaviour under windows.

Any idea?

TIA



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