From: Gurusamy Sarathy Date: Mon, 7 Feb 2000 19:01:08 +0000 (+0000) Subject: stringify "\x{FFF}" to utf8 correctly; set SvUTF8 on "\x{XX}" X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=234a4bc6763f850602ce9515d905ee1c14f004d4;p=p5sagit%2Fp5-mst-13.2.git stringify "\x{FFF}" to utf8 correctly; set SvUTF8 on "\x{XX}" only when XX > 127 p4raw-id: //depot/perl@5033 --- diff --git a/pp_hot.c b/pp_hot.c index 6ef302c..8dab651 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -87,6 +87,8 @@ PP(pp_stringify) char *s; s = SvPV(TOPs,len); sv_setpvn(TARG,s,len); + if (SvUTF8(TOPs) && !IN_BYTE) + SvUTF8_on(TARG); SETTARG; RETURN; } diff --git a/toke.c b/toke.c index 3410ab5..34599bd 100644 --- a/toke.c +++ b/toke.c @@ -1356,18 +1356,24 @@ S_scan_const(pTHX_ char *start) ++s; if (*s == '{') { char* e = strchr(s, '}'); + UV uv; if (!e) { yyerror("Missing right brace on \\x{}"); e = s; } /* note: utf always shorter than hex */ - d = (char*)uv_to_utf8((U8*)d, - (UV)scan_hex(s + 1, e - s - 1, &len)); + uv = (UV)scan_hex(s + 1, e - s - 1, &len); + if (uv > 127) { + d = (char*)uv_to_utf8((U8*)d, uv); + has_utf = TRUE; + } + else + *d++ = (char)uv; s = e + 1; - has_utf = TRUE; } else { + /* XXX collapse this branch into the one above */ UV uv = (UV)scan_hex(s, 2, &len); if (utf && PL_lex_inwhat == OP_TRANS && utf != (OPpTRANS_FROM_UTF|OPpTRANS_TO_UTF))