Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I did a bit of studying (DBM-Deep-1.0016).

  • write_value uses class DBM::Deep::Engine::Sector::Scalar for everything but references and undef.
  • ::Scalar::_init receives the value and passes it to print_at.
  • print_at expects a string of bytes. It's getting a string that contains non-bytes.

No encoding is done anywhere, as far as I've seen. Definitely a major bug. Two possible fixes:

  • Have DBM::Deep::Engine::Sector::Scalar's _init encode values.
  • Add another Sector type for strings with UTF8=1.

The latter should be simpler, more efficient, and allows the preservation of the UTF8 flag. Basically, adjust write_value and add

package DBM::Deep::Engine::Sector::Unicode; use 5.006_000; use strict; use warnings FATAL => 'all'; no warnings 'recursion'; use base qw( DBM::Deep::Engine::Sector::Scalar ); sub type { $_[0]{engine}->SIG_UNICODE } sub _init { my $self = shift; utf8::encode( $self->{data} ) if $] >= 5.008 && defined($self->{data}); $self->SUPER::_init(); } sub data { my $self = shift; my $data = $self->SUPER::data(); utf8::decode( $data ) if $] >= 5.008; return $data; } 1; __END__

And that's just for values. A separate fix is needed for the keys, I believe.

In reply to Re^2: "wide character in print" error in DBM::Deep by ikegami
in thread "wide character in print" error in DBM::Deep by jdporter

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, 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, 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.
  • Log In?

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

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (5)
    As of 2018-09-24 02:33 GMT
    Find Nodes?
      Voting Booth?
      Eventually, "covfefe" will come to mean:

      Results (191 votes). Check out past polls.

      • (Sep 10, 2018 at 22:53 UTC) Welcome new users!