Package: perl-base
Version: 5.8.8-4
Severity: normal
Tags: l10n

I am trying to write a locale aware program. As I understand the
perl documentation (mainly the man page perllocale) perl is currently
dealing only with output (I will discuss this man page in a different
wishlist bug later). So I attempt to construct an input routine.

The following programm, which is taken almost verbatim from the man
page, does not work as advertised, i.e. setlocale() seems to return
"C", regardless of the actual locale settings.

[EMAIL PROTECTED]:~/prog/db/rechnung$ less locale_info.pl
#!/usr/bin/perl

use POSIX qw(locale_h);

# Get a reference to a hash of locale-dependent info
$locale_values = localeconv();

# Output sorted list of the values
for (sort keys %$locale_values) {
        printf "%-20s = %s\n", $_, $locale_values->{$_}
}

# query and save the old locale
$old_locale = setlocale(LC_NUMERIC);
print "LC_NUMERIC: $old_locale\n";

No look at the follwing output:
[EMAIL PROTECTED]:~/prog/db/rechnung$ bash
[EMAIL PROTECTED]:~/prog/db/rechnung$ export LANG=de_DE
[EMAIL PROTECTED]:~/prog/db/rechnung$ export LC_ALL=de_DE
[EMAIL PROTECTED]:~/prog/db/rechnung$ export LC_NUMERIC=de_DE
[EMAIL PROTECTED]:~/prog/db/rechnung$ ./locale_info.pl
currency_symbol      = EUR
decimal_point        = .
frac_digits          = 2
int_curr_symbol      = EUR
int_frac_digits      = 2
mon_decimal_point    = ,
mon_grouping         =
mon_thousands_sep    = .
n_cs_precedes        = 0
n_sep_by_space       = 1
n_sign_posn          = 1
negative_sign        = -
p_cs_precedes        = 0
p_sep_by_space       = 1
p_sign_posn          = 1
LC_NUMERIC: C
~~~~~~~~~~~~~
If I use LC_CTYPE instead of LC_NUMERIC, it *does* work. (Note, that
decimal_point is incorrectly set to "." instead of "," - I reported
this against locales in #379329, but I tend to believe this to be a
perl problem in reality).

Next I take another example from perllocale(1):
[EMAIL PROTECTED]:~/prog/db/rechnung$ cat lcnumeric.pl
#!/usr/bin/perl

use POSIX qw(strtod);
use locale;

$n = 5/2;   # Assign numeric 2.5 to $n

$a = " $n"; # Locale-dependent conversion to string

print "half five is $n\n";       # Locale-dependent output

printf "half five is %g\n", $n;  # Locale-dependent output

print "DECIMAL POINT IS COMMA\n"
    if $n == (strtod("2,5"))[0]; # Locale-dependent conversion

and run it as well:
[EMAIL PROTECTED]:~/prog/db/rechnung$ ./lcnumeric.pl
half five is 2.5
half five is 2.5
DECIMAL POINT IS COMMA

Now this programm still prints "2.5" (not 2,5 as proper) but *claims*
that the decimal point is in fact a comma???

Unfortunately I have no idea how to debug this, I simply wanted to use
the facilities provided by perl :-((

-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (500, 'testing'), (500, 'stable')
Architecture: amd64 (x86_64)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.14.6-grsec-cz03
Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=ISO-8859-15)

Versions of packages perl-base depends on:
ii  libc6                         2.3.6-15   GNU C Library: Shared libraries

perl-base recommends no packages.

-- no debconf information
-- 
      Dr. Helge Kreutzmann                     [EMAIL PROTECTED]
           Dipl.-Phys.                   http://www.helgefjell.de/debian.php
        64bit GNU powered                     gpg signed mail preferred
           Help keep free software "libre": http://www.ffii.de/

Attachment: signature.asc
Description: Digital signature

Reply via email to