httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Wheeler <da...@kineticode.com>
Subject Re: Apache::Request, APR::Table and UTF8
Date Wed, 06 Oct 2004 00:10:01 GMT
On Oct 5, 2004, at 4:55 PM, Stas Bekman wrote:

> What you and Boris say makes perfect sense, but we certainly don't 
> want to try to support all possible formats out there and try to 
> handle those on behalf of users. If we do we may need to spawn 
> APR::Table to be a project on its own with its own dedicated 
> developers team. this is something suitable for Apache::Request which 
> deals with a sub-set of formats, it's not suitable for APR::Table 
> which is a general purpose thing.

Yes, I'm not talking about remembering what character set a string is 
in, only about preserving the value of the Perl utf8 flag.

> I don't know if it's a good idea to have APR::Table to deal only with 
> utf8 as the only special case. Joe?

Only if you consider a need to support any other Perl variable flags as 
special cases. Again, I'm just thinking of the value of the flag, not 
the encoding of the data in the string.

> sure, but you can make it a perl scalar.
>
> string "foo" on the way to the table:
>
> utf8     => "1foo";
> non-utf8 => "0foo"
>
> on the way out, split and check the first char, and set the flag 
> accordingly. Won't that work?

Yes, but I don't want to have to do that work, just as I wouldn't want 
to serialize and deserialize hash or array references to store them in 
a table. You don't have to do that, do you?

>> # Store
>> while (my ($k, $v) = each %stringmap) {
>>     $r->pnotes( $k => $v );
>>     $r->pnotes( "$k.utf8" => Encode::is_utf8($v);
>> }
>> # Fetch:
>> my %stringmap;
>> while (my ($k, $v) = each %{ {$r->pnotes }}) {
>>     next if $k =~ /\.utf8$/;
>>     Encode::_utf8_on($v) if $r->pnotes("$k.utf");
>>     $stringmap{$k} = $v;
>> }
>> This is an extreme example, but I think that it makes the case. apreq 
>> has to be able to know what kind of scalar it has, anyway, so it 
>> should be able to know if the string is decoded to Perl's internal 
>> utf8 representation, and if so, make sure it keeps the utf8 flag on.
>
> You certainly have no need to do that since pnotes already preserve 
> the perl flags.

Phew, that's nice! But I meant to apply it to APR::Table.

Regards,

David


Mime
View raw message