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

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

From:
Karl Williamson via RT
Date:
January 11, 2012 13:53
Subject:
[perl #35949] 'use locale' does not enable number formatting locale
Message ID:
rt-3.6.HEAD-14510-1326318803-1167.35949-15-0@perl.org
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'
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'
12345,67


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=35949



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About