e = (U8 *) SvEND(sv);
t = s;
while (t < e) {
- if ((hibit = UTF8_IS_CONTINUED(NATIVE_TO_ASCII(*t++))))
+ if ((hibit = !UTF8_IS_INVARIANT(*t++)))
break;
}
if (hibit) {
Perl_sv_utf8_decode(pTHX_ register SV *sv)
{
if (SvPOK(sv)) {
- char *c;
- char *e;
+ U8 *c;
+ U8 *e;
/* The octets may have got themselves encoded - get them back as bytes */
if (!sv_utf8_downgrade(sv, TRUE))
/* it is actually just a matter of turning the utf8 flag on, but
* we want to make sure everything inside is valid utf8 first.
*/
- c = SvPVX(sv);
- if (!is_utf8_string((U8*)c, SvCUR(sv)+1))
+ c = (U8 *) SvPVX(sv);
+ if (!is_utf8_string(c, SvCUR(sv)+1))
return FALSE;
- e = SvEND(sv);
+ e = (U8 *) SvEND(sv);
while (c < e) {
- if (UTF8_IS_CONTINUED(*c++)) {
+ if (!UTF8_IS_INVARIANT(*c++)) {
SvUTF8_on(sv);
break;
}
case 'c':
uv = args ? va_arg(*args, int) : SvIVx(argsv);
- if ((uv > 255 || (uv > 127 && SvUTF8(sv))) && !IN_BYTE) {
+ if ((uv > 255 || (!UTF8_IS_INVARIANT(uv) && SvUTF8(sv))) && !IN_BYTE) {
eptr = (char*)utf8buf;
elen = uvchr_to_utf8((U8*)eptr, uv) - utf8buf;
is_utf = TRUE;
/* We need to map to chars to ASCII before doing the tests
to cover EBCDIC
*/
- if (NATIVE_TO_UNI(uv) > 127) {
+ if (!UTF8_IS_INVARIANT(uv)) {
if (!has_utf8 && uv > 255) {
/* Might need to recode whatever we have
* accumulated so far if it contains any
* this rescan? --jhi)
*/
int hicount = 0;
- char *c;
- for (c = SvPVX(sv); c < d; c++) {
- if (UTF8_IS_CONTINUED(NATIVE_TO_ASCII(*c))) {
+ U8 *c;
+ for (c = (U8 *) SvPVX(sv); c < (U8 *)d; c++) {
+ if (!UTF8_IS_INVARIANT(*c)) {
hicount++;
}
}
- if (hicount || NATIVE_TO_ASCII('A') != 'A') {
+ if (hicount) {
STRLEN offset = d - SvPVX(sv);
U8 *src, *dst;
d = SvGROW(sv, SvLEN(sv) + hicount + 1) + offset;
dst = src+hicount;
d += hicount;
while (src >= (U8 *)SvPVX(sv)) {
- U8 ch = NATIVE_TO_ASCII(*src);
- if (UTF8_IS_CONTINUED(ch)) {
+ if (!UTF8_IS_INVARIANT(*src)) {
+ U8 ch = NATIVE_TO_ASCII(*src);
*dst-- = UTF8_EIGHT_BIT_LO(ch);
*dst-- = UTF8_EIGHT_BIT_HI(ch);
}
else {
- *dst-- = ch;
+ *dst-- = *src;
}
src--;
}
} /* end if (backslash) */
default_action:
-#ifndef EBCDIC
/* The 'has_utf8' here is very dubious */
- if (UTF8_IS_CONTINUED(NATIVE_TO_ASCII(*s)) && (this_utf8 || has_utf8)) {
+ if (!UTF8_IS_INVARIANT((U8)(*s)) && (this_utf8 || has_utf8)) {
STRLEN len = (STRLEN) -1;
UV uv;
if (this_utf8) {
}
continue;
}
-#endif
*d++ = NATIVE_TO_NEED(has_utf8,*s++);
} /* while loop to process each character */
missingterm((char*)0);
yylval.ival = OP_CONST;
for (d = SvPV(PL_lex_stuff, len); len; len--, d++) {
- if (*d == '$' || *d == '@' || *d == '\\' || UTF8_IS_CONTINUED(*d)) {
+ if (*d == '$' || *d == '@' || *d == '\\' || !UTF8_IS_INVARIANT((U8)*d)) {
yylval.ival = OP_STRINGIFY;
break;
}
/* after skipping whitespace, the next character is the terminator */
term = *s;
- if (UTF8_IS_CONTINUED(term) && UTF)
+ if (!UTF8_IS_INVARIANT((U8)term) && UTF)
has_utf8 = TRUE;
/* mark where we are */
have found the terminator */
else if (*s == term)
break;
- else if (!has_utf8 && UTF8_IS_CONTINUED(*s) && UTF)
+ else if (!has_utf8 && !UTF8_IS_INVARIANT((U8)*s) && UTF)
has_utf8 = TRUE;
*to = *s;
}
break;
else if (*s == PL_multi_open)
brackets++;
- else if (!has_utf8 && UTF8_IS_CONTINUED(*s) && UTF)
+ else if (!has_utf8 && !UTF8_IS_INVARIANT((U8)*s) && UTF)
has_utf8 = TRUE;
*to = *s;
}