Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

Re: APR::Table lost UTF8 flag: msg#00250

apache.mod-perl.devel

Subject: Re: APR::Table lost UTF8 flag

Boris Zentner wrote:

Hi,

Am 24.09.2004 um 14:30 schrieb Joe Schaefer:

Boris Zentner <bzm@xxxxxx> 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:stas@xxxxxxxxxx http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
version-control...    qnx.openqnx.dev...    redhat.rhn.user...    ietf.openpgp/20...    mail.mutt.user/...    web.microformat...    java.sync4j.use...    education.ezpro...    user-groups.blu...    solaris.manager...    org.fitug.debat...    technology.erps...    politics.activi...    linux.redhat.fe...    bug-tracking.ma...    xfce.user/2004-...    hams/2004-11/ms...    kde.users.pim/2...    culture.cooking...    freebsd.devel.x...    gnu.m4.adhoc/20...    ngpt.user/2002-...    apple.fink.deve...   
Home | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation