Here's a test program:

#!/usr/bin/perl use strict; use warnings; use Test::More tests => 8; use Data::Dumper qw( Dumper ); use DBM::Deep qw(); use File::Temp qw( tempfile ); my ($fh, $fn) = tempfile(); my $db = DBM::Deep->new( $fn ); sub _u { utf8::upgrade( my $s = $_[0] ); $s } sub _d { utf8::downgrade( my $s = $_[0] ); $s } $db->{A} = "\x61"; $db->{B} = _d("\xA0"); $db->{C} = _u("\xA0"); $db->{D} = "\x{2660}"; $db->{"\x61" } = 1; $db->{_d("\xA0")} = 1; $db->{_u("\xA0")} = 1; $db->{"\x{2660}"} = 1; my @keys = sort keys %$db; is( 0+@keys, 7, "Num keys" ) or diag('Got ' . do { local $Data::Dumper::Useqq = 1; local $Data::Dumper::Terse = 1; local $Data::Dumper::Indent = 0; Dumper(\@keys) }); is( $keys[4], "\x61", "7-bit key" ); is( $keys[5], "\xA0", "8-bit key" ); is( $keys[6], "\x{2660}", "32-bit key" ); is( $db->{A}, "\x61", "7-bit val" ); is( $db->{B}, "\xA0", "8-bit val (UTF8=0)" ); is( $db->{C}, "\xA0", "8-bit val (UTF8=1)" ); is( $db->{D}, "\x{2660}", "32-bit val" );

Output:

1..8 Wide character in print at /home/eric/lib/perl5/DBM/Deep/File.pm line +193. # Looks like your test exited with 9 before it could output anything.

To validate the test, I ran it after replacing
my $db = DBM::Deep->new( $fn );
with
my $db = {};

Update: Fixed bugs in test.


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

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.