develooper Front page | perl.perl5.porters | Postings from April 2003

[perl #21948] Encoding woes with s///e

Thread Next
From:
Antti Lankila
Date:
April 13, 2003 18:53
Subject:
[perl #21948] Encoding woes with s///e
Message ID:
rt-21948-55056.2.91436620503148@bugs6.perl.org
# New Ticket Created by  Antti Lankila 
# Please include the string:  [perl #21948]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=21948 >


This is a bug report for perl from alankila@korppi.elma.fi,
generated with the help of perlbug 1.34 running under perl v5.8.0.


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

Is this intended behaviour, or a bug?

$str = "test_me äö";
$str2 = $str;
my $break = decode("ISO-8859-15", "¤"); # Euro in unicode
$str =~ s/./$break/;
$str2 =~ s/./$break/e;
print $str;  # prints 3 wide chars like 'â¬est_me äö'
print $str2; # only prints one wide character: 'â¬est_me äö'

Something stinks here.

If I now try to encode the $str and $str2 back to ISO-8859-15,
$str comes out ok with euro symbol, but the $str2 has lost äö
because the string was promoted to utf8 representation but the
pre-existing characters were not encoded appropriately!

print encode("ISO-8859-15", $str);  # prints ¤est_me äö
print encode("ISO-8859-15", $str2); # prints ¤est_me ?

My workaround: decode $str2, or encode $break within the expression
before the substitution takes place.

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=medium
---
Site configuration information for perl v5.8.0:

Configured by alankila at Thu Aug 22 14:13:36 EEST 2002.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.4.18, archname=i686-linux-thread-multi-ld
    uname='linux korppi.elma.fi 2.4.18 #1 smp mon may 20 00:01:31 eest 2002 i686 unknown '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=define
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-O2',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -I/usr/local/include -I/usr/include/gdbm'
    ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.1 2.96-85)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='long double', nvsize=12, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldl -lm -lpthread -lc -lcrypt -lutil
    perllibs=-lnsl -ldl -lm -lpthread -lc -lcrypt -lutil
    libc=/lib/libc-2.2.4.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.2.4'
  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 v5.8.0:
    /home/alankila/private_html/devel/lib
    /opt/perl5/5.8.0-thread/lib/5.8.0/i686-linux-thread-multi-ld
    /opt/perl5/5.8.0-thread/lib/5.8.0
    /opt/perl5/5.8.0-thread/lib/site_perl/5.8.0/i686-linux-thread-multi-ld
    /opt/perl5/5.8.0-thread/lib/site_perl/5.8.0
    /opt/perl5/5.8.0-thread/lib/site_perl
    .

---
Environment for perl v5.8.0:
    HOME=/home/alankila
    LANG=C
    LANGUAGE (unset)
    LC_CTYPE=fi_FI@euro
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin
    PERL5LIB=/home/alankila/private_html/devel/lib
    PERL_BADLANG (unset)
    SHELL=/usr/bin/zsh

-- 
alankila@elma.net (Antti Lankila, P. +358 50 386 6217)
Platform Manager // Elma Oyj Electronic Trading



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