Subject: | behaviour with utf8=0 |
With utf8=0 Cache::Memcached::Fast should try to utf8::downgrade string before sending it to socket (that's the way perl print/syswrite work (on binary filehandles), MIME::Base64, Digest::SHA, any other perl function/code modules etc).
if downgrade fails it should wanr or die.
the following test should not fail:
===
use strict;
use warnings;
use Cache::Memcached::Fast;
my $memd = Cache::Memcached::Fast->new({utf8 => 0, servers => [ '127.0.0.1:11211' ]});
my $s = "\x81";
my $s_u = $s;
utf8::upgrade $s_u;
die unless $s eq $s_u;
$memd->set("XYZ", $s_u);
my $s_u2 = $memd->get("XYZ");
die "data corupted" unless $s_u2 eq $s_u;
===
currently it fails with "data corupted"
here is similar code, but print/readline used instead of memcached with binary filehandle.
everything works fine.
===
use strict;
use warnings;
my $s = "\x81";
my $s_u = $s;
utf8::upgrade $s_u;
die unless $s eq $s_u;
open my $f, ">", "file.tmp";
binmode $f;
print $f $s_u;
close $f;
open $f, "<", "file.tmp";
my ($s_u2) = <$f>;
close $f;
die "data corupted" unless $s_u2 eq $s_u;
===