develooper Front page | perl.perl5.porters | Postings from February 2001

[ID 20010225.003] inconsistencies in locale support

Thread Next
From:
andrew
Date:
February 25, 2001 09:03
Subject:
[ID 20010225.003] inconsistencies in locale support
Message ID:
m14X4Z1-005a5rC@pimlott.ne.mediaone.net
This is a bug report for perl from andrew@pimlott.ne.mediaone.net,
generated with the help of perlbug 1.26 running under perl 5.00503.


-----------------------------------------------------------------
[Please enter your report here]

I'm trying to understand Perl's traditional locale support, and finding it
frustratingly inconsistent.  I created the following program

#!/usr/bin/perl

use locale;
use POSIX;
$c1 = chr 0xc0;
$c2 = tolower $c1;
$c3 = lc $c1;
__END__

and ran it in the debugger with LANG=en_US.  The transcript is at the end,
but in short, tolower always returns the same character, and lc works as
expected in the program, but not on the debugger command line.  The POSIX
documentation says that tolower is identical to lc, and neither the POSIX
nor perldebug documentation mention any interaction between locales and the
debugger.

My locale support seems to work fine with a simple C program such as

#include <locale.h>

main()
{
    unsigned char c = 0xc0;
    unsigned char c2;
    setlocale (LC_ALL, "");
    c2 = tolower(c);
    printf("%c (%x) -> %c (%x)\n", c, c, c2, c2);
}

Andrew

PS.  This message is in ISO-8859-1; the character 0xc0 is "LATIN CAPITAL
LETTER A WITH GRAVE", and 0xe0 is "LATIN SMALL LETTER A WITH GRAVE".

% LANG=en_US perl -d ./try2

Loading DB routines from perl5db.pl version 1.0402
Emacs support available.

Enter h or `h h' for help.

main::(./try2:5):       $c1 = chr 0xc0;
  DB<1> n
main::(./try2:6):       $c2 = tolower $c1;
  DB<1> 
main::(./try2:7):       $c3 = lc $c1;
  DB<1> 
Debugged program terminated.  Use q to quit or R to restart,
  use O inhibit_exit to avoid stopping after program termination,
  h q, h R or h O to get additional info.  
  DB<1> x $c1
0  'À'
  DB<2> x $c2
0  'À'
  DB<3> x $c3
0  'à'
  DB<4> x tolower $c1
0  'À'
  DB<5> x lc $c1
0  'À'
  DB<6> q



[Please do not change anything below this line]
-----------------------------------------------------------------

---
Site configuration information for perl 5.00503:

Configured by drow at Sun Apr 30 12:07:23 EDT 2000.

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
    osname=linux, osvers=2.2.15pre14, archname=i386-linux
    uname='linux them 2.2.15pre14 #2 smp mon mar 13 14:29:00 est 2000 i686 unknown '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-O2 ', gccversion=2.95.2 20000313 (Debian GNU/Linux)
    cppflags='-Dbool=char -DHAS_BOOL -D_REENTRANT -DDEBIAN -I/usr/local/include'
    ccflags ='-Dbool=char -DHAS_BOOL -D_REENTRANT -DDEBIAN -I/usr/local/include'
    stdchar='char', d_stdstdio=undef, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldbm -ldb -ldl -lm -lc -lposix -lcrypt
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl 5.00503:
    /home/andrew/local/lib/perl5
    /usr/lib/perl5/5.005/i386-linux
    /usr/lib/perl5/5.005
    /usr/local/lib/site_perl/i386-linux
    /usr/local/lib/site_perl
    /usr/lib/perl5
    .

---
Environment for perl 5.00503:
    HOME=/home/andrew
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/andrew/bin:/usr/sbin:/sbin:/usr/bin:/bin:/usr/sbin:/sbin
    PERL5LIB=/home/andrew/local/lib/perl5
    PERL_BADLANG (unset)
    SHELL=/usr/bin/zsh


Thread Next


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