Hi,
Whenever I store something into a APR::Table I get different data back. Even with a recent mod_perl I use
APR::Table stores plain strings. It doesn't know what type of a string it has stored. If you store utf8 data you need to tell perl that the string is utf8, by calling Encode::encode. It's exactly the same as getting some UTF8 data from the client, you need explicitly decode it to make Perl see it as UTF8 data.
Server: Apache/2.0.50 (Unix) mod_perl/1.99_16 Perl/v5.8.4 SVN/1.1.0-rc2 mod_ssl/2.0.50 OpenSSL/0.9.7d DAV/2
Here is my prove, call it with http://your_server/something
############################ START ################################ <Perl> package XX; use APR::Table; use Encode; use APR::Pool; use Devel::Peek; use Apache::Const qw/OK/;
sub testHandler : method { my $r = shift; my $str = "\x{f6}\x{e4}\x{fc}"; my $utf8 = Encode::decode( 'iso-8859-1', $str ); my $p = $r->pool->new; my $t = APR::Table::make( $p, 10 ); $t->set( aa => $str ); $t->set( bb => $utf8 ); my $aa = $t->get('aa'); my $bb = $t->get('bb'); my $messages = ''; { close STDERR; open *STDERR, '>', \$messages or die $!; Dump $str; Dump $utf8; Dump $aa; Dump $bb; } print "Content-Type: text/plain; charset=ISO-8859-1\n\n"; print $messages, "\n", "is $str eq $utf8 ? ", ( $str eq $utf8 ? "yes" : "no" ), "\n", "is $utf8 eq $bb ? ", ( $utf8 eq $bb ? "yes" : "no" ), "\n"; Apache::OK(); } 1;
</Perl> <Location /> SetHandler perl-script PerlHandler XX::testHandler </Location> ###################################### END ##############################
This is the output from my system:
Content-Type: text/plain; charset=ISO-8859-1
SV = PV(0x1a48774) at 0x1a5b7a4 REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK) PV = 0x2b67550 "\366\344\374"\0 CUR = 3 LEN = 4 SV = PVMG(0x1b17300) at 0x1a48afc REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK,UTF8) IV = 0 NV = 0 PV = 0x2b67cc0 "\303\266\303\244\303\274"\0 [UTF8 "\x{f6}\x{e4}\x{fc}"] CUR = 6 LEN = 7 MAGIC = 0x2b67310 MG_VIRTUAL = &PL_vtbl_utf8 MG_TYPE = PERL_MAGIC_utf8(w) MG_LEN = 3 SV = PV(0x1acd900) at 0x1a5d484 REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK) PV = 0x2b671d0 "\366\344\374"\0 CUR = 3 LEN = 4 SV = PV(0x1acd8e8) at 0x1a5d4c0 REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK) PV = 0x2b67390 "\303\266\303\244\303\274"\0 CUR = 6 LEN = 7
is ��� eq ��� ? yes is ��� eq öäü ? no
-- Boris
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] g
-- __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
