You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Torsten Foertsch <to...@gmx.net> on 2009/03/10 09:55:58 UTC
BerkeleyDB solution
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