diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2001-01-05 00:47:23 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-01-05 00:47:23 +0000 |
commit | a0dbb04553005cdbafdeb7435a79ae500b5aa8ff (patch) | |
tree | c3c2af7757f55ba66089c19094e138ecb04cb469 /doop.c | |
parent | 7a800fca3140c85b8a41515633e9bb98c38e5603 (diff) | |
download | perl-a0dbb04553005cdbafdeb7435a79ae500b5aa8ff.tar.gz |
Unify UTF-8 malformedness handling.
p4raw-id: //depot/perl@8323
Diffstat (limited to 'doop.c')
-rw-r--r-- | doop.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -833,15 +833,15 @@ Perl_do_chop(pTHX_ register SV *astr, register SV *sv) char *send = s + len; char *start = s; s = send - 1; - while ((*s & 0xc0) == 0x80) - --s; - if (UTF8SKIP(s) != send - s && ckWARN_d(WARN_UTF8)) - Perl_warner(aTHX_ WARN_UTF8, "Malformed UTF-8 character"); - sv_setpvn(astr, s, send - s); - *s = '\0'; - SvCUR_set(sv, s - start); - SvNIOK_off(sv); - SvUTF8_on(astr); + while (s > start && UTF8_IS_CONTINUATION(*s)) + s--; + if (utf8_to_uv_simple((U8*)s, 0)) { + sv_setpvn(astr, s, send - s); + *s = '\0'; + SvCUR_set(sv, s - start); + SvNIOK_off(sv); + SvUTF8_on(astr); + } } else sv_setpvn(astr, "", 0); |