From 89afcb60a8aa0fcded9f2490166a9f2c4cb540f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=B6nig?= Date: Mon, 22 Apr 2002 14:08:48 +0200 Subject: New UTF-8 surprise Message-ID: p4raw-id: //depot/perl@16124 --- pp_hot.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'pp_hot.c') diff --git a/pp_hot.c b/pp_hot.c index 492b50be17..027d1249ac 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)); -- cgit v1.2.1