skazat has asked for the wisdom of the Perl Monks concerning the following question:
Hello everyone,
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:
Storable binary image v35.114 more recent than I am (v2.8) at blib/lib +/Storable.pm (autosplit into blib/lib/auto/Storable/thaw.al) line 421 +, at ../perllib/MLDBM/Serializer/Storable.pm line 27
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: MLDBM and UTF-8
by ig (Vicar) on Feb 28, 2011 at 07:08 UTC |