Regarding Storable, the error message is indicating that the binary data it is trying to retrieve was written by Storable version 35.114. Since current version is 2.8, it seems most likely that you are trying to read corrupt data.
I wrote a small test using Storable and it appears to work.
use strict; use warnings; use MLDBM qw(DB_File Storable); use Devel::Peek; use Encode; use FreezeThaw; no warnings 'utf8'; $| = 1; tie my %data, 'MLDBM', 'testmldbm' or die $!; my $string = "a string with a wide character: \x{0100}"; Dump($string); #my $fstring = FreezeThaw::freeze($string); $data{string} = $string; print "$data{string}\n";
It produced the following output, but cut-and-paste seems to have mangled the wide character. It looks like a capital A with a bar above it on my terminal:
SV = PV(0x9766470) at 0x964eae8 REFCNT = 1 FLAGS = (PADMY,POK,pPOK,UTF8) PV = 0x97a5190 "a string with a wide character: \304\200"\0 [UTF8 "a + string with a wide character: \x{100}"] CUR = 34 LEN = 36 a string with a wide character: Ā
Changing the script to use FreezeThaw, it reproduces your error. This appears to be a limitation of DB_File. Apparently FreezeThaw passes the wide characters through to DB_File while Storable does not.
Maybe you can use FreezeThaw with a filter, something like the following:
use strict; use warnings; use MLDBM qw(DB_File FreezeThaw); use Devel::Peek; use Encode; use FreezeThaw; no warnings 'utf8'; use Data::Dumper; use DBM_Filter; $| = 1; my $db = tie my %data, 'MLDBM', 'testmldbm' or die $!; print Dumper($db->{DB}); $db->{DB}->Filter_Push('utf8'); if($db->{DB}->can('Filter_Push')) { print "can Filter_Push\n"; } my $string = "a string with a wide character: \x{0100}"; Dump($string); $data{string} = $string; print "$data{string}\n";
With the filter added, this test script does not produce the Wide character error - it seems to work.
In reply to Re: MLDBM and UTF-8
by ig
in thread MLDBM and UTF-8
by skazat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |