Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#25600 - [perl] LC_NUMERIC always C

Attached to Project: Arch Linux
Opened by Silvio Knizek (killermoehre) - Tuesday, 16 August 2011, 10:44 GMT
Last edited by Dave Reisner (falconindy) - Thursday, 18 August 2011, 19:53 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Angel Velasquez (angvp)
Florian Pritz (bluewind)
Architecture x86_64
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
In perl LC_NUMERIC is always C and can't be changed, but this is important for my company because in german we use a decimal comma instead of a decimal point (see http://dict.leo.org/forum/viewWrongentry.php?idThread=224942&idForum=7&lang=en).

Additional info:
* package version
perl v5.14.1

Steps to reproduce:
compare
$ locale | grep LC_NUMERIC
with
$ perl -MPOSIX -e 'print setlocale(LC_NUMERIC), "\n"'
This task depends upon

Closed by  Dave Reisner (falconindy)
Thursday, 18 August 2011, 19:53 GMT
Reason for closing:  Not a bug
Additional comments about closing:  see comments, working as intended.
Comment by Dan McGee (toofishes) - Tuesday, 16 August 2011, 21:51 GMT
According to this: http://perldoc.perl.org/perllocale.html#The-use-locale-pragma

1. You need to use 'use locale' in your program.
2. LC_NUMERIC is always set to 'C'. Now why, I have no idea, but this is an upstream issue, not something we can really deal with, so for any further action on this you'll have to take it there.
Comment by Justin Davis (juster) - Thursday, 18 August 2011, 16:06 GMT
I think you are just using setlocale wrong. setlocale in the POSIX module acts the same as setlocale in C (see: man 3 setlocale). The locale starts off as POSIX-compatible (C) until you change it by using setlocale. This was confusing for me the first time I used it.

setlocale with only one argument (like your example) only queries the current locale. Since it has not been changed yet, it is C. AKA POSIX-compatible. setlocale with a second argument of an empty string ("") will set the locale according to the environment variables of the process. This is the same behavior as the C library function.

In order to set the locale you should use the empty string, like so:
$ perl -MPOSIX -E 'say setlocale(LC_NUMERIC, q{}); printf qq{%0.2f\n}, 3.14'

Here I used -E in order to use say. q{} is the same as '' (the empty string) but helps me to avoid single quotes in bash. qq{} is the same as double-quotes in perl.

Hope that helps.

edit: "use locale" won't help because it only sets LC_CTYPE and LC_COLLATE. For something similar to "use locale", for setting all locale categories, replace LC_NUMERIC above with LC_ALL.

Loading...