perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "laurent dami" <>
Subject [BUG] (or feature?) : no I/O layers in Apache2::RequestIO, native 8-bit and unicode strings are different
Date Sun, 26 Mar 2006 01:19:41 GMT
# Perl internal strings are either native 8-bit or Unicode. Usually this
# is totally transparent to users because of Perl I/O layers. But
# unfortunately Apache2::RequestIO does not seem to know about this.
# Here is a short ModPerl::Registry script to show it.

my $r = shift;

my $s1 = "il était une bergère"; # native 8-bit (i.e. latin1)
my $s2 = $s1; 
utf8::upgrade($s2);              # change internal encoding to utf8

sub encoding {utf8::is_utf8(shift) ? 'utf8' : 'native 8-bit';}

# s1 is in native 8-bit, s2 is in utf8
printf "s1 is in %s, s2 is in %s\n", encoding($s1), encoding($s2);

# both strings are equal
printf "both strings are %s\n", ($s1 eq $s2 ? "equal" : "not equal");
print "yet ...\n";

my @strings = ($s1, " // ", $s2, "\n");
    print("printed EQUAL     through core::print :        ", @strings);  
$r->print("printed DIFFERENT through Apache2::RequestIO : ", @strings);

View raw message