develooper Front page | perl.perl5.porters | Postings from January 2012

[perl #35949] 'use locale' does not enable number formatting locale

Karl Williamson via RT
January 11, 2012 13:53
[perl #35949] 'use locale' does not enable number formatting locale
Message ID:
After some investigation, and some bug fixes, I am closing this ticket,
as it works as designed.  Perl goes to some trouble to make the decimal
point a period even in the face of a locale to the contrary.  To
override this, a setlocale() call is required, as Phillip said.  I do
not know the motivation behind this, but it has worked that way for a
long time.  Some of the text of perllocale.pod was modified by me in
5.14 to clarify that the setlocale() call is needed (based on reading
the code),though other text in it already indicated this. 

The patches that I knew about have now been applied. There may be bugs
remaining, they're not the one described in this ticket.  I don't have
an nl locale on my box, but I do have a de one, and changing the program
in the original ticket to use setlocale(), gets it to work.

original ticket:
LANG=de_DE.utf8 perl -e 'use locale; printf "%.2f\n", 12345.67'

modified so works as documentd:
LANG=de_DE.utf8 perl -e 'use locale; use POSIX qw(locale_h);
setlocale(LC_ALL, ""); printf "%.2f\n", 12345.67'

via perlbug:  queue: perl5 status: open Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About