[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Localized number output with format ~h
From: |
Ludovic Courtès |
Subject: |
Localized number output with format ~h |
Date: |
Fri, 03 Feb 2012 17:09:22 +0100 |
User-agent: |
Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.93 (gnu/linux) |
Hello Guilers!
Our beloved ‘format’ now supports locale-dependent number output, using
the new ~h format specifier:
~h
Localized number(1). Parameters: WIDTH, DECIMALS, PADCHAR.
Like ~f, output an exact or floating point number, but do so
according to the current locale, or according to the given
locale object when the `:' modifier is used (*note
`number->locale-string': Number Input and Output.).
(format #t "~h" 12345.5678) ; with "C" as the current locale
-| 12345.5678
(format #t "~14,,'*:h" 12345.5678
(make-locale LC_ALL "en_US"))
-| ***12,345.5678
(format #t "~,2:h" 12345.5678
(make-locale LC_NUMERIC "fr_FR"))
-| 12 345,56
The difference with ~f is that it doesn’t have the SCALE and
OVERFLOWCHAR parameters (it would be doable but seems overkill to me),
and it supports the ‘:’ modifier to specify a locale object.
I would appreciate comments on the interface, since it will basically be
around forever.
Also, if you’re aware of other Schemes that have a ‘format’-like
procedure that supports localized number output, it may be a good idea
to try to choose an interface close to theirs (like using a whatever
letter they use instead of ~h.)
Thanks!
Ludo’.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Localized number output with format ~h,
Ludovic Courtès <=