[Gnucash-changes] r13433 - gnucash/trunk - Rework of Sylvain Defresne's patch to support multi-byte unicode

David Hampton hampton at cvs.gnucash.org
Wed Mar 1 18:01:44 EST 2006


Author: hampton
Date: 2006-03-01 18:01:43 -0500 (Wed, 01 Mar 2006)
New Revision: 13433
Trac: http://svn.gnucash.org/trac/changeset/13433

Modified:
   gnucash/trunk/ChangeLog
   gnucash/trunk/src/app-utils/gnc-ui-util.c
Log:
Rework of Sylvain Defresne's patch to support multi-byte unicode
thousands separator and decimal point characters when printing
numbers.


Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog	2006-03-01 20:01:37 UTC (rev 13432)
+++ gnucash/trunk/ChangeLog	2006-03-01 23:01:43 UTC (rev 13433)
@@ -1,3 +1,9 @@
+2006-03-01  David Hampton  <hampton at employees.org>
+
+	* src/app-utils/gnc-ui-util.c: Rework of Sylvain Defresne's patch
+	to support multi-byte unicode thousands separator and decimal
+	point characters when printing numbers.
+
 2006-03-01  Derek Atkins  <derek at ihtfp.com>
 
 	* src/report/standard-reports/transaction.scm:

Modified: gnucash/trunk/src/app-utils/gnc-ui-util.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-ui-util.c	2006-03-01 20:01:37 UTC (rev 13432)
+++ gnucash/trunk/src/app-utils/gnc-ui-util.c	2006-03-01 23:01:43 UTC (rev 13433)
@@ -1156,7 +1156,7 @@
 {
   struct lconv *lc = gnc_localeconv();
   int num_whole_digits;
-  char temp_buf[64];
+  char temp_buf[128];
   gnc_numeric whole, rounding;
   int min_dp, max_dp;
 
@@ -1218,19 +1218,20 @@
   else
   {
     int group_count;
-    char separator;
+    char *separator;
     char *temp_ptr;
     char *buf_ptr;
     char *group;
+    gchar *rev_buf;
 
     if (info->monetary)
     {
-      separator = lc->mon_thousands_sep[0];
+      separator = lc->mon_thousands_sep;
       group = lc->mon_grouping;
     }
     else
     {
-      separator = lc->thousands_sep[0];
+      separator = lc->thousands_sep;
       group = lc->grouping;
     }
 
@@ -1248,7 +1249,8 @@
 
         if (group_count == *group)
         {
-          *buf_ptr++ = separator;
+	  g_utf8_strncpy(buf_ptr, separator, 1);
+	  buf_ptr = g_utf8_find_next_char(buf_ptr, NULL);
           group_count = 0;
 
           /* Peek ahead at the next group code */
@@ -1272,7 +1274,9 @@
     /* We built the string backwards, now reverse */
     *buf_ptr++ = *temp_ptr;
     *buf_ptr = '\0';
-    g_strreverse(buf);
+    rev_buf = g_utf8_strreverse(buf, -1);
+    strcpy (buf, rev_buf);
+    g_free(rev_buf);
   } /* endif */
 
   /* at this point, buf contains the whole part of the number */
@@ -1296,11 +1300,14 @@
   }
   else
   {
+    char *decimal_point;
     guint8 num_decimal_places = 0;
     char *temp_ptr = temp_buf;
 
-    *temp_ptr++ = info->monetary ?
-      lc->mon_decimal_point[0] : lc->decimal_point[0];
+    decimal_point = info->monetary ?
+      lc->mon_decimal_point : lc->decimal_point;
+    g_utf8_strncpy(temp_ptr, decimal_point, 1);
+    temp_ptr = g_utf8_find_next_char(temp_ptr, NULL);
 
     while (!gnc_numeric_zero_p (val) && (val.denom != 1) &&
 	   (num_decimal_places < max_dp))



More information about the gnucash-changes mailing list