[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Formatted output with locale
From: |
Vladimir Zhbanov |
Subject: |
Re: Formatted output with locale |
Date: |
Thu, 17 Nov 2016 19:53:25 +0300 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Thu, Nov 17, 2016 at 12:02:06PM +0100, Ludovic Courtès wrote:
> Hi!
>
> address@hidden skribis:
>
> > 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
>
> It seems to work as advertised for me:
>
> --8<---------------cut here---------------start------------->8---
> scheme@(guile-user)> ,use(ice-9 i18n)
> scheme@(guile-user)> (number->locale-string 10000.01 2 (make-locale LC_ALL
> "fr_FR.utf8"))
> $13 = "10 000,01"
> scheme@(guile-user)> (number->locale-string 10000.01 2 (make-locale LC_ALL
> "de_DE.utf8"))
> $14 = "10.000,01"
> scheme@(guile-user)> ,use(ice-9 format)
> scheme@(guile-user)> (setlocale LC_ALL "de_DE.utf8")
> $15 = "de_DE.utf8"
> scheme@(guile-user)> (format #f "~12,2h" 10000.01)
> $16 = " 10.000,01"
> --8<---------------cut here---------------end--------------->8---
What does it output if you type
(number->locale-string 10000.00 2 (make-locale LC_ALL "fr_FR.utf8"))
that is with two zeros after the point?
I would expect the same two zeros if the second argument is
2... Am I wrong?
> That’s on GNU/Linux (glibc 2.24).
>
> Note that number formatting data comes from the C library. What C
> library do you use?
My glibc version is 2.19.
Thanks
--
Vladimir