if (!preeminent) {
STRLEN keylen;
const char * const key = SvPV_const(keysv, keylen);
- SAVEDELETE(hv, savepvn(key,keylen), keylen);
+ SAVEDELETE(hv, savepvn(key,keylen),
+ SvUTF8(keysv) ? -(I32)keylen : keylen);
} else
save_helem(hv, keysv, svp);
}
ptr = SSPOPPTR;
hv = (HV*)ptr;
ptr = SSPOPPTR;
- (void)hv_delete(hv, (char*)ptr, (U32)SSPOPINT, G_DISCARD);
+ (void)hv_delete(hv, (char*)ptr, (I32)SSPOPINT, G_DISCARD);
SvREFCNT_dec(hv);
Safefree(ptr);
break;
chdir 't' if -d 't';
require './test.pl';
}
-plan tests => 95;
+plan tests => 104;
my $list_assignment_supported = 1;
::ok(f1() eq "f1", "localised sub restored");
::ok(f2() eq "f2", "localised sub restored");
}
+
+# Localising unicode keys (bug #38815)
+{
+ 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} = 256;
+ local $h{$ambigous} = 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");
+}