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.

-skazat

In reply to MLDBM and UTF-8 by skazat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.