[Gambas-user] Format$ thousand separator

Epíleg epileg at ...626...
Sun Dec 23 15:16:08 CET 2007


En/na Benoit Minisini ha escrit:
> On jeudi 20 décembre 2007, Epíleg wrote:
>> En/na Benoit Minisini ha escrit:
>>> On mercredi 19 décembre 2007, Epíleg wrote:
>>>> En/na Benoit Minisini ha escrit:
>>>>> On mercredi 19 décembre 2007, Benoit Minisini wrote:
>>>>>> On mercredi 19 décembre 2007, Epíleg wrote:
>>>>>>> Hello,
>>>>>>>
>>>>>>> I do not get the thousand separator whit the «format$» function, some
>>>>>>> examples:
>>>>>>>
>>>>>>>
>>>>>>> PRINT Format$(1000000, "$$,#.00")  =>  EUR 1 000 000,00
>>>>>>>
>>>>>>> PRINT Format$(1000000, "$,#.00")  =>  € 1 000 000,00
>>>>>>>
>>>>>>> PRINT Format$(1000000, ",#.00")  =>  1000000,00
>>>>>>>
>>>>>>>
>>>>>>> What I'm doing wrong?
>>>>>>>
>>>>>>> These tests are done in a Ubuntu Gutsy (7.10) with «ca_ES.UTF-8»
>>>>>>> locale
>>>>>>>
>>>>>>> Regards,
>>>>>>> Epíleg.
>>>>>> Apparently, this is a bug!
>>>>> The last revision now takes thousand separators into account.
>>>>>
>>>>> But be careful that in the GNU locales, many languages have thousand
>>>>> separators only for currencies.
>>>>>
>>>>> So, when a locale does not have any thousands separator, a space is
>>>>> used, and the value is splitted each three digits. Maybe this is a bad
>>>>> idea that will be removed in the future!
>>>>>
>>>>> Regards,
>>>> Thanks!
>>>>
>>>> In an Ubuntu 7.10 with locale en_US.UTF-8 and en_GB.UTF-8, the thousand
>>>> separator works fine also with numbers, but with locale ca_ES.UTF-8 and
>>>> es_ES.UTF-8 do not works with numbers (spaces added). In both cases the
>>>> currencies thousand separator works fine.
>>>>
>>>> Excuse my ignorance but in an Open Office Spread document, format
>>>> function works correctly with numbers and currencies in all of above
>>>> locale and I don't know why.
>>>>
>>>> Thanks a lot,
>>>> Epíleg.
>>> The locale information is stored in /usr/share/locale/XXX where XXX is
>>> the contents of the LC_* environment variable.
>>>
>>> Gambas uses this information through the standard Unix API. If I set my
>>> environment to es_ES, then I have no standard thousands separator, and a
>>> point for currency thousands separator.
>>>
>>> Maybe Open Office does not use this information. Maybe it uses it, but
>>> patches it as Gambas does.
>>>
>>> For example, KDE uses its own locale information, in
>>> the /usr/share/locale/l10n/xxx/entry.desktop file.
>>>
>>> Regards,
>> Thank You for Your answer.
>>
>> From My absolutely ignorance and understanding that this is a locale
>> problem, isn't a solution to use the currency thousand separator in numbers
>> when this info is missing?
>>
>> Regards,
>> Epíleg.
>>
> 
> Yes, but if the locale tells that there is no separators with non-currency 
> numbers, maybe it is right? I must know if it is a bug or not to take a 
> decision!
> 

In my system, Ubuntu 7.10, I got this:

$ LANG=ca_ES.UTF-8 locale -k LC_NUMERIC
decimal_point=","
thousands_sep=""
grouping=-1;-1
numeric-decimal-point-wc=44
numeric-thousands-sep-wc=0
numeric-codeset="UTF-8"

$ LANG=es_ES.UTF-8 locale -k LC_NUMERIC
decimal_point=","
thousands_sep=""
grouping=-1;-1
numeric-decimal-point-wc=44
numeric-thousands-sep-wc=0
numeric-codeset="UTF-8"

$ LANG=es_AR.UTF-8 locale -k LC_NUMERIC
decimal_point=","
thousands_sep="."
grouping=3;3
numeric-decimal-point-wc=44
numeric-thousands-sep-wc=46
numeric-codeset="UTF-8"

$ LANG=en_US.UTF-8 locale -k LC_NUMERIC
decimal_point="."
thousands_sep=","
grouping=3;3
numeric-decimal-point-wc=46
numeric-thousands-sep-wc=44
numeric-codeset="UTF-8"

$ LANG=fr_FR.UTF-8 locale -k LC_NUMERIC
decimal_point=","
thousands_sep=" "
grouping=3;3
numeric-decimal-point-wc=44
numeric-thousands-sep-wc=32
numeric-codeset="UTF-8"

$ LANG=de_DE.UTF-8 locale -k LC_NUMERIC
decimal_point=","
thousands_sep="."
grouping=3;3
numeric-decimal-point-wc=44
numeric-thousands-sep-wc=46
numeric-codeset="UTF-8"

Gambas2 do as locale informs so isn't a Gambas2 bug.

For me is clear that this is a bug in the data of Catalan and Spanish locale. There are 3 fields with wrong thousands data.

Do You know the way to solve this bug?

Regards,
Epíleg.





More information about the User mailing list