Rework of Sylvain Defresne's patch to support multi-byte unicode

thousands separator and decimal point characters when printing
numbers.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13433 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
David Hampton
2006-03-01 23:01:43 +00:00
parent 1fb65d3ab5
commit 7694d2f473
2 changed files with 21 additions and 8 deletions

View File

@@ -1,3 +1,9 @@
2006-03-01 David Hampton <hampton@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@ihtfp.com>
* src/report/standard-reports/transaction.scm:

View File

@@ -1156,7 +1156,7 @@ PrintAmountInternal(char *buf, gnc_numeric val, const GNCPrintAmountInfo *info)
{
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 @@ PrintAmountInternal(char *buf, gnc_numeric val, const GNCPrintAmountInfo *info)
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 @@ PrintAmountInternal(char *buf, gnc_numeric val, const GNCPrintAmountInfo *info)
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 @@ PrintAmountInternal(char *buf, gnc_numeric val, const GNCPrintAmountInfo *info)
/* 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 @@ PrintAmountInternal(char *buf, gnc_numeric val, const GNCPrintAmountInfo *info)
}
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))