perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Foertsch <torsten.foert...@gmx.net>
Subject BerkeleyDB solution
Date Tue, 10 Mar 2009 08:55:58 GMT
Hi,

this is not a problem but a solution. I know some of you use the 
BerkeleyDB module to store data. Recently I have tried to use UTF8 keys 
and failed. When reading back keys I sometimes got character strings 
sometimes octet strings. I had used the following 2 filters to ensure 
the data in the database is octet strings and the data I get back are 
character strings:

  $db->filter_fetch_key(sub { $_=Encode::decode('utf8', $_) });
  $db->filter_store_key(sub { $_=Encode::encode('utf8', $_) });

The problem is BerkeleyDB doesn't reset the UTF8 bit when storing data 
to @_ variables as in c_get() or db_get(). One possible solution is

  $db->filter_fetch_key(sub {
    Encode::_utf8_off($_);
    $_=Encode::decode('utf8', $_);
  });

The other/better one is to fix it in BerkeleyDB.xs. This is what the 
attached patch does. I have sent it to the author, Paul Marquess. Here 
is his reply:

On Tue 10 Mar 2009, Paul Marquess wrote:
> Your patch looks fine and should be ok to include in my development
> copy without any changes.

Torsten

-- 
Need professional mod_perl support?
Just hire me: torsten.foertsch@gmx.net

Mime
View raw message