good chemistry is complicated,
and a little bit messy -LW
MLDBM and UTF-8by skazat (Hermit)
|on Feb 25, 2011 at 19:26 UTC||Need Help??|
skazat has asked for the
wisdom of the Perl Monks concerning the following question:
I'm having trouble saving UTF-8 text using MLDB.
I understand that the value needs to be encoded on save and decoded before being used, but MLDB provides a additional problem, since you're not just passing a string to it, but instead a complex data structure - you cannot attempt to encode the complex data structure and think that's going to do the trick - it doesn't even make sense.
This means you probably need to encode/decode (at the right time) each value separately.
Is there any easy way to do this? It seems that you would have to walk through the entire data structure itself. Sadly, I don't know a bulletproof way to do that, in this instance. I do know the format of what to expect of this data structure, but it may change in time. Mostly, it's just a hashref of hashrefs, perhaps with some arrayrefs - no objects, or strange things like that.
Has anyone already stumbled on this problem?
Attempting to save a value with an unencoded UTF-8 string in one of values in a complex data structure using MLDBM will give back this error:
Wide character in subroutine entry at ../perllib/MLDBM.pm line 161.
I'm using MLDBM with the FreezeThaw backend:
use MLDBM qw(DB_File FreezeThaw);
as using Storable: use MLDBM qw(DB_File Storable);
produces this delightful error:
Which makes very very little sense to me at all.
35.114? My brothers/sisters, I'm sincerely lost in the woods, with this one.