From: Andreas König Date: Mon, 22 Apr 2002 12:08:48 +0000 (+0200) Subject: New UTF-8 surprise X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=89afcb60a8aa0fcded9f2490166a9f2c4cb540f8;p=p5sagit%2Fp5-mst-13.2.git New UTF-8 surprise Message-ID: p4raw-id: //depot/perl@16124 --- diff --git a/pp_hot.c b/pp_hot.c index 492b50b..027d124 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -2117,7 +2117,14 @@ PP(pp_subst) break; } while (CALLREGEXEC(aTHX_ rx, s, strend, orig, s == m, TARG, NULL, r_flags)); - sv_catpvn(dstr, s, strend - s); + if (doutf8 && !DO_UTF8(dstr)) { + SV* nsv = sv_2mortal(newSVpvn(s, strend - s)); + + sv_utf8_upgrade(nsv); + sv_catpvn(dstr, SvPVX(nsv), SvCUR(nsv)); + } + else + sv_catpvn(dstr, s, strend - s); (void)SvOOK_off(TARG); Safefree(SvPVX(TARG)); diff --git a/t/op/subst.t b/t/op/subst.t index e48a1b3..8b0a8b0 100755 --- a/t/op/subst.t +++ b/t/op/subst.t @@ -7,7 +7,7 @@ BEGIN { } require './test.pl'; -plan( tests => 88 ); +plan( tests => 89 ); $x = 'foo'; $_ = "x"; @@ -374,3 +374,8 @@ ok( $_ eq "C B" && $snum == 12 ); $r =~ s/[^\w\.]//g; is($l, $r, "use utf8"); } + +my $pv1 = my $pv2 = "Andreas J. K\303\266nig"; +$pv1 =~ s/A/\x{100}/; +substr($pv2,0,1) = "\x{100}"; +is($pv1, $pv2);