From: Spider Boardman Date: Thu, 14 Sep 2000 17:09:36 +0000 (-0400) Subject: Replace #7084 with X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9f9ab9055319ce9b1a2b147cb13f3474dcc9c3b7;p=p5sagit%2Fp5-mst-13.2.git Replace #7084 with Subject: Re: perl@7078 Message-Id: <200009142109.RAA03425@leggy.zk3.dec.com> p4raw-id: //depot/perl@7085 --- diff --git a/sv.c b/sv.c index 6e332c5..039e7d6 100644 --- a/sv.c +++ b/sv.c @@ -2437,7 +2437,7 @@ Perl_sv_utf8_downgrade(pTHX_ register SV* sv, bool fail_ok) { if (SvPOK(sv) && SvUTF8(sv)) { char *c = SvPVX(sv); - STRLEN len = SvCUR(sv); + STRLEN len = SvCUR(sv) + 1; /* include trailing NUL */ if (!utf8_to_bytes((U8*)c, &len)) { if (fail_ok) return FALSE; @@ -2445,6 +2445,7 @@ Perl_sv_utf8_downgrade(pTHX_ register SV* sv, bool fail_ok) Perl_croak("big byte"); } SvCUR(sv) = len - 1; + SvUTF8_off(sv); } return TRUE; } diff --git a/utf8.c b/utf8.c index 6ae92bd..d97a8b0 100644 --- a/utf8.c +++ b/utf8.c @@ -299,7 +299,8 @@ Perl_utf8_to_bytes(pTHX_ U8* s, STRLEN *len) /* ensure valid UTF8 and chars < 256 before updating string */ while (s < send) { U8 c = *s++; - if ( (s >= send) || (*s & 0x80 && c > 0xc3)) { + if (c >= 0x80 && + ( (s >= send) || ((*s++ & 0xc0) != 0x80) || ((c & 0xfe) != 0xc2))) { *len = -1; return 0; }