Hi,
Am 24.09.2004 um 14:30 schrieb Joe Schaefer:
Boris Zentner <[EMAIL PROTECTED]> writes:
[...]
It makes only sense the other way around. A $apr->param('parameter'); must provide a valid object.
That's why I suggested subclassing Apache::Request, so you can have param() do whatever you want.
Thats what I'm doing already. But this is only a hack and not a solution.
- I lost all the speed from libapreq2 im really slow since I have to copy all the data to a perl object only for the lost bit.
- Since I subclass, a user can call params and get a APR::Table object that is totally unrelated to the data he is interested in.
But thats my solution unless APR::Table gets fixed.
In this email I'm not talking about libapreq which uses a sub-class of APR::Table.
To start with: APR::Table stores plain strings, it has no way to store metadata. You need to use pnotes to store perl variables (which will preserve any of the flags).
It's possible that if APR::Table sees a UTF8 flag on set(), it should encode it back to the utf8 string before storing it, since as you've pointed out there is no way to restore the UTF8 flag back. But also as you've pointed out, it's a huge waste of resources. since you will need to decoded it again, when you get() it and before you can use it.
May be expicitly setting the utf8 flag will work as a temp solution for you? If all your data is stored in utf8, then it will perfectly fine.
Below is the revision of your test program, that does what you want. (If you didn't know, you can use APR:: classes outside of Apache, so you can run this program from the command line):
use Apache2;
use APR::Table; use Encode; use APR::Pool; use Devel::Peek;
my $p = APR::Pool->new; my $t = APR::Table::make($p, 10 );
my $str = "\x{f6}\x{e4}\x{fc}"; my $utf8 = Encode::decode( 'iso-8859-1', $str );
$t->set( aa => $str ); $t->set( bb => $utf8 );
my $aa = $t->get('aa'); my $bb = $t->get('bb');
Encode::_utf8_on($bb);
Dump $str; Dump $utf8; Dump $aa; Dump $bb;
print "is $str eq $utf8 ? ", ( $str eq $utf8 ? "yes" : "no" ), "\n", "is $utf8 eq $bb ? ", ( $utf8 eq $bb ? "yes" : "no" ), "\n";
-- __________________________________________________________________ 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]