Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-19 12:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found