diff options
-rw-r--r-- | pp_hot.c | 10 | ||||
-rwxr-xr-x | t/op/subst.t | 2 |
2 files changed, 8 insertions, 4 deletions
@@ -1983,16 +1983,20 @@ PP(pp_subst) /* known replacement string? */ if (dstr) { - c = SvPV(dstr, clen); - doutf8 = DO_UTF8(dstr); /* replacement needing upgrading? */ if (DO_UTF8(TARG) && !doutf8) { - SV *nsv = sv_2mortal(newSVpvn(c, clen)); + SV *nsv = sv_newmortal(); + SvSetSV(nsv, dstr); if (PL_encoding) sv_recode_to_utf8(nsv, PL_encoding); else sv_utf8_upgrade(nsv); c = SvPV(nsv, clen); + doutf8 = TRUE; + } + else { + c = SvPV(dstr, clen); + doutf8 = DO_UTF8(dstr); } } else { diff --git a/t/op/subst.t b/t/op/subst.t index f691aff957..3fa6a9aef3 100755 --- a/t/op/subst.t +++ b/t/op/subst.t @@ -408,7 +408,7 @@ is($pv1, $pv2); $a = "\x{100}\x{101}"; $a =~ s/\x{101}/\xFF/; like($a, qr/\xFF/); - is(length($a), 2); + is(length($a), 2, "SADAHIRO utf8 s///"); $a = "\x{100}\x{101}"; $a =~ s/\x{101}/"\xFF"/e; |