From 2395af1a33d775da23471cd1f8f82356494fc723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Wed, 16 Sep 2015 22:51:31 +0000 Subject: [PATCH] [INTERPRETER] * BUG: Fix thousand separator for locales like norwegian that return an UTF-8 non-breaking space. Replace it by a normal space. git-svn-id: svn://localhost/gambas/trunk@7318 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- main/gbx/gbx_local.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/main/gbx/gbx_local.c b/main/gbx/gbx_local.c index dcbc102b8..e35757558 100644 --- a/main/gbx/gbx_local.c +++ b/main/gbx/gbx_local.c @@ -356,6 +356,17 @@ static void free_local_info(void) CLEAR(&LOCAL_local); } +static char fix_separator(const char *str) +{ + if (!*str || !str[1]) + return str[0]; + + if ((uchar)str[0] == 0xC2 && (uchar)str[1] == 0xA0 && str[2] == 0) + return ' '; + + return '?'; +} + static void fill_local_info(void) { struct lconv *info; @@ -399,7 +410,7 @@ static void fill_local_info(void) //fprintf(stderr, "'%s' '%s'\n", nl_langinfo(THOUSANDS_SEP), nl_langinfo(MON_THOUSANDS_SEP)); LOCAL_local.decimal_point = *(info->decimal_point); - LOCAL_local.thousand_sep = *(info->thousands_sep); + LOCAL_local.thousand_sep = fix_separator(info->thousands_sep); if (LOCAL_local.thousand_sep == 0) LOCAL_local.thousand_sep = ' '; LOCAL_local.group_size = *(info->grouping); @@ -537,11 +548,8 @@ static void fill_local_info(void) lang = LOCAL_get_lang(); if (strcmp(lang, "fr") == 0 || strncmp(lang, "fr_", 3) == 0) - { LOCAL_local.date_sep = '/'; - //LOCAL_local.thousand_sep = '~'; - } - + stradd_sep(LOCAL_local.general_date, LOCAL_local.long_time, " "); am_pm = nl_langinfo(AM_STR); if (am_pm && *am_pm) @@ -555,7 +563,7 @@ static void fill_local_info(void) // Currency format - LOCAL_local.currency_thousand_sep = *(info->mon_thousands_sep); + LOCAL_local.currency_thousand_sep = fix_separator(info->mon_thousands_sep); if (LOCAL_local.currency_thousand_sep == 0) LOCAL_local.currency_thousand_sep = ' '; LOCAL_local.currency_group_size = *(info->mon_grouping);