GNU bug report logs -
#24990
Wrong formatted output with 'number->locale-string'
Previous Next
Reported by: Martin Michel <dev <at> famic.de>
Date: Tue, 22 Nov 2016 22:09:01 UTC
Severity: normal
Done: ludo <at> gnu.org (Ludovic Courtès)
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 24990 in the body.
You can then email your comments to 24990 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-guile <at> gnu.org
:
bug#24990
; Package
guile
.
(Tue, 22 Nov 2016 22:09:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Martin Michel <dev <at> famic.de>
:
New bug report received and forwarded. Copy sent to
bug-guile <at> gnu.org
.
(Tue, 22 Nov 2016 22:09:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi there,
I want to report a bug in the format module using different locales.
It seems that 'number->locale-string' and 'monetary-amount->locale-string'
are broken.
Please see below emails sent to the guile-users mailing list how to
reproduce the behaviour. The Guile version I used was 2.0.13.
Thanks,
-Martin
----- Forwarded message from Vladimir Zhbanov <vzhbanov <at> gmail.com> -----
Date: Mon, 14 Nov 2016 09:03:19 +0300
From: Vladimir Zhbanov <vzhbanov <at> gmail.com>
To: dev <at> famic.de
Subject: Re: Formatted output with locale
Hi Martin,
On 11/13/16, dev <at> famic.de <dev <at> famic.de> wrote:
> Hi there,
> I have problems to get a proper formatting using the (ice-9 format)
> module. In my code, I need to deal with monetary figures, but I fail
> to get the correct format for my German locale.
> Let's say I have one hundred thousand Euros. The correct format to output
> this in de_DE.utf-8 would be
> 100.000,00 EUR
> (with 2 decimals)
>
> Now I tried:
> (setlocale LC_ALL "de_DE.UTF-8")
> (use-modules (ice-9 format))
> (define a 100000.00)
> (format #t "~12,2h EUR~%" a)
> (format #t "~,,12$ EUR~%" a)
> (format #t "~12,2f EUR~%" a)
>
> But this is what Guile gives to me:
> 100.000,0 EUR
> 100000.00 EUR
> 100000.00 EUR
>
> None is correct. What did I miss?
> -Martin
Looking at the `format' code for option `h' I see the procedure
`number->locale-string' is used.
OK, let's do some experiments:
scheme@(guile-user)> (setlocale LC_ALL)
$2 = "ru_RU.UTF-8"
scheme@(guile-user)> ,use (ice-9 i18n)
scheme@(guile-user)> (number->locale-string 10.0 5)
$3 = "10,0"
scheme@(guile-user)> (number->locale-string .00003 2)
$4 = "3,0e"
scheme@(guile-user)> (number->locale-string .00003 1)
$5 = "3,0"
scheme@(guile-user)> (number->locale-string .00003 3)
$6 = "3,0e-"
scheme@(guile-user)> (number->locale-string .0 3)
$7 = "-0,0"
scheme@(guile-user)> (number->locale-string .0 10)
$8 = "-0,0"
scheme@(guile-user)> (number->locale-string .0 1)
$9 = "-0,0"
Now for the procedure monetary-amount->locale-string:
scheme@(guile-user)> (monetary-amount->locale-string .0 #t)
$10 = "-0.0 RUB "
scheme@(guile-user)> (monetary-amount->locale-string 100000.0 #t)
$11 = "100\xa0000.0 RUB "
scheme@(guile-user)> (monetary-amount->locale-string .00003 #t)
$12 = "3.0e RUB "
And my guile version:
scheme@(guile-user)> (version)
$13 = "2.0.11"
It seems `number->locale-string' is broken. If I do, e.g.
(number->locale-string .00003 10)
it yields
"3,0e-5"
If the last arg decreases, it just trims the number of
characters after comma, which is wrong in this case.
Output for zero is funny, too.
Regards,
Vladimir
----- End forwarded message -----
----- End forwarded message -----
Reply sent
to
ludo <at> gnu.org (Ludovic Courtès)
:
You have taken responsibility.
(Sun, 12 Feb 2017 23:25:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Martin Michel <dev <at> famic.de>
:
bug acknowledged by developer.
(Sun, 12 Feb 2017 23:25:02 GMT)
Full text and
rfc822 format available.
Message #10 received at 24990-done <at> debbugs.gnu.org (full text, mbox):
Hi,
Martin Michel <dev <at> famic.de> skribis:
> From: Vladimir Zhbanov <vzhbanov <at> gmail.com>
> Subject: Re: Formatted output with locale
> To: dev <at> famic.de, 24990 <at> debbugs.gnu.org
> Date: Mon, 14 Nov 2016 09:03:19 +0300 (12 weeks, 6 days, 15 hours ago)
>
> Hi Martin,
>
> On 11/13/16, dev <at> famic.de <dev <at> famic.de> wrote:
>> Hi there,
>> I have problems to get a proper formatting using the (ice-9 format)
>> module. In my code, I need to deal with monetary figures, but I fail
>> to get the correct format for my German locale.
>> Let's say I have one hundred thousand Euros. The correct format to output
>> this in de_DE.utf-8 would be
>> 100.000,00 EUR
>> (with 2 decimals)
>>
>> Now I tried:
>> (setlocale LC_ALL "de_DE.UTF-8")
>> (use-modules (ice-9 format))
>> (define a 100000.00)
>> (format #t "~12,2h EUR~%" a)
>> (format #t "~,,12$ EUR~%" a)
>> (format #t "~12,2f EUR~%" a)
>>
>> But this is what Guile gives to me:
>> 100.000,0 EUR
>> 100000.00 EUR
>> 100000.00 EUR
>>
>> None is correct. What did I miss?
>> -Martin
>
> Looking at the `format' code for option `h' I see the procedure
> `number->locale-string' is used.
>
> OK, let's do some experiments:
>
> scheme@(guile-user)> (setlocale LC_ALL)
> $2 = "ru_RU.UTF-8"
> scheme@(guile-user)> ,use (ice-9 i18n)
> scheme@(guile-user)> (number->locale-string 10.0 5)
> $3 = "10,0"
> scheme@(guile-user)> (number->locale-string .00003 2)
> $4 = "3,0e"
> scheme@(guile-user)> (number->locale-string .00003 1)
> $5 = "3,0"
> scheme@(guile-user)> (number->locale-string .00003 3)
> $6 = "3,0e-"
> scheme@(guile-user)> (number->locale-string .0 3)
> $7 = "-0,0"
> scheme@(guile-user)> (number->locale-string .0 10)
> $8 = "-0,0"
> scheme@(guile-user)> (number->locale-string .0 1)
> $9 = "-0,0"
>
> Now for the procedure monetary-amount->locale-string:
>
> scheme@(guile-user)> (monetary-amount->locale-string .0 #t)
> $10 = "-0.0 RUB "
> scheme@(guile-user)> (monetary-amount->locale-string 100000.0 #t)
> $11 = "100\xa0000.0 RUB "
> scheme@(guile-user)> (monetary-amount->locale-string .00003 #t)
> $12 = "3.0e RUB "
I believe these are fixed by commit
4aead68cdb86ca60cc372f0cd558cadda90ddec5.
You’re welcome to do more testing and report back!
Thanks,
Ludo’.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 13 Mar 2017 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 7 years and 18 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.