[json-glib] Doubles are converted to strings containing commas



commit 7cebdd008a02e6cef0514f40327f94eba2a2088e
Author: Cornelius Hald <hald icandy de>
Date:   Thu Nov 12 11:37:54 2009 +0000

    Doubles are converted to strings containing commas
    
    Under some locales (e.g. de_DE) a double is converted to a string
    containing a comma instead of a dot. That breaks the JSON syntax.
    
    Example:
    Double: 0.34 is converted to 0,34 when using locale de_DE
    
    http://bugzilla.openedhand.com/show_bug.cgi?id=1826
    
    Signed-off-by: Emmanuele Bassi <ebassi linux intel com>

 json-glib/json-generator.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/json-glib/json-generator.c b/json-glib/json-generator.c
index c17d97f..bad239b 100644
--- a/json-glib/json-generator.c
+++ b/json-glib/json-generator.c
@@ -306,7 +306,12 @@ dump_value (JsonGenerator *generator,
       break;
 
     case G_TYPE_DOUBLE:
-      g_string_append_printf (buffer, "%f", g_value_get_double (&value));
+      {
+        gchar buf[65];
+
+        g_ascii_formatd (buf, 65, "%d", g_value_get_double (&value));
+        g_string_append (buffer, buf);
+      }
       break;
 
     case G_TYPE_BOOLEAN:



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