Subject: | error mixing LC_NUMERIC and LC_MONETARY |
Date: | Sun, 11 May 2008 10:41:14 +1000 |
To: | bug-number-format [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
In the debian packaged perl 5.10.0 and Number::Format 1.52, the program
foo.pl below produces
Number::Format: {thousands_sep} and {decimal_point} may not be equal
at foo.pl line 10
where I hoped it'd print "123.45".
The combination in foo.pl of "C" for numeric and something european for
monetary isn't as perverse as it sounds. In fact if you set LANG=de_DE
then that combination seems to be the default perl starts up with!
Nosing around I guess new() decides to use mon_thousands_sep as a
fallback for thousands_sep, but in de_DE that's a '.' the same as the
decimal_point of C locale. I think it'd be good not to mix LC_NUMERIC
and LC_MONETARY values, better take decimal+thousands together as a pair
in whatever fallbacks are used.
Those initializations might be worsened by the way POSIX::localeconv()
seems to omit "thousands_sep" altogether from its return when the
thousands sep is an empty string, like in "C" locale. This sounds wrong
to me, maybe there's a reason for it, I guess some care is needed not to
be tricked by it though.
But this is assuming an empty thousands sep is supposed to work. I see
in the docs "... must each be one character", which I guess is not true
of the "C" locale. If that really is a requirement then take this
instead as a request to relax that :-), since I think no thousands sep
is a fairly reasonable thing to do, I've dropped it for instance when
running short of columns on a tty.
Message body is not shown because sender requested not to inline it.