diff options
Diffstat (limited to 'toke.c')
-rw-r--r-- | toke.c | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -1383,7 +1383,8 @@ S_scan_const(pTHX_ char *start) else { STRLEN len = 1; /* allow underscores */ uv = (UV)scan_hex(s + 1, e - s - 1, &len); - to_be_utf8 = TRUE; + if (PL_hints & HINT_UTF8) + to_be_utf8 = TRUE; } s = e + 1; } @@ -1425,8 +1426,6 @@ S_scan_const(pTHX_ char *start) if (hicount) { char *old_pvx = SvPVX(sv); char *src, *dst; - U8 tmpbuf[UTF8_MAXLEN+1]; - U8 *tmpend; d = SvGROW(sv, SvCUR(sv) + hicount + 1) + @@ -1438,10 +1437,8 @@ S_scan_const(pTHX_ char *start) while (src < dst) { if (UTF8_IS_CONTINUED(*src)) { - tmpend = uv_to_utf8(tmpbuf, (U8)*src--); - dst -= tmpend - tmpbuf; - Copy((char *)tmpbuf, dst+1, - tmpend - tmpbuf, char); + *dst-- = UTF8_EIGHT_BIT_LO(*src); + *dst-- = UTF8_EIGHT_BIT_HI(*src--); } else { *dst-- = *src--; @@ -1450,7 +1447,7 @@ S_scan_const(pTHX_ char *start) } } - if (to_be_utf8 || (has_utf8 && uv > 127) || uv > 255) { + if (to_be_utf8 || has_utf8 || uv > 255) { d = (char*)uv_to_utf8((U8*)d, uv); has_utf8 = TRUE; } |