You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by laurent dami <la...@free.fr> on 2006/03/26 03:19:41 UTC

[BUG] (or feature?) : no I/O layers in Apache2::RequestIO, native 8-bit and unicode strings are different

# 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;
$r->content_type('text/plain');

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);