else {
STRLEN keylen;
const char *key = SvPV_const(keysv, keylen);
- SAVEDELETE(hv, savepvn(key,keylen), keylen);
+ SAVEDELETE(hv, savepvn(key,keylen),
+ SvUTF8(keysv) ? -keylen : keylen);
}
}
}
chdir 't' if -d 't';
require './test.pl';
}
-plan tests => 104;
+plan tests => 113;
my $list_assignment_supported = 1;
is($h{"\243"}, "pound");
is($h{"\302\240"}, "octects");
}
+
+# And with slices
+{
+ my %h;
+ $h{"\243"} = "pound";
+ $h{"\302\240"} = "octects";
+ is(scalar keys %h, 2);
+ {
+ my $unicode = chr 256;
+ my $ambigous = "\240" . $unicode;
+ chop $ambigous;
+ local @h{$unicode, $ambigous} = (256, 160);
+
+ is(scalar keys %h, 4);
+ is($h{"\243"}, "pound");
+ is($h{$unicode}, 256);
+ is($h{$ambigous}, 160);
+ is($h{"\302\240"}, "octects");
+ }
+ is(scalar keys %h, 2);
+ is($h{"\243"}, "pound");
+ is($h{"\302\240"}, "octects");
+}