From: Jarkko Hietaniemi Date: Sun, 18 Feb 2001 18:41:33 +0000 (+0000) Subject: UTF-8 tweaks. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=90f44359bb7541a575a1666f79be58a556605cf6;p=p5sagit%2Fp5-mst-13.2.git UTF-8 tweaks. p4raw-id: //depot/perl@8827 --- diff --git a/sv.c b/sv.c index 1098680..ea360c3 100644 --- a/sv.c +++ b/sv.c @@ -4724,17 +4724,15 @@ Perl_sv_eq(pTHX_ register SV *sv1, register SV *sv2) if (SvUTF8(sv1)) { char *pv = (char*)bytes_from_utf8((U8*)pv1, &cur1, &is_utf8); - if (is_utf8) - return 0; - pv1tmp = (pv != pv1); - pv1 = pv; + + if ((pv1tmp = (pv != pv1))) + pv1 = pv; } else { char *pv = (char *)bytes_from_utf8((U8*)pv2, &cur2, &is_utf8); - if (is_utf8) - return 0; - pv2tmp = (pv != pv2); - pv2 = pv; + + if ((pv2tmp = (pv != pv2))) + pv2 = pv; } } diff --git a/utf8.c b/utf8.c index a36cc74..918b669 100644 --- a/utf8.c +++ b/utf8.c @@ -625,10 +625,11 @@ Perl_bytes_from_utf8(pTHX_ U8* s, STRLEN *len, bool *is_utf8) s = start; start = d; while (s < send) { U8 c = *s++; + if (UTF8_IS_ASCII(c)) *d++ = c; else - *d++ = UTF8_ACCUMULATE(c&3, *s++); + *d++ = UTF8_ACCUMULATE(c, *s++); } *d = '\0'; *len = d - start; @@ -657,12 +658,13 @@ Perl_bytes_to_utf8(pTHX_ U8* s, STRLEN *len) dst = d; while (s < send) { - if (*s < 0x80) + if (UTF8_IS_ASCII(*s)) *d++ = *s++; else { UV uv = *s++; - *d++ = (( uv >> 6) | 0xc0); - *d++ = (( uv & 0x3f) | 0x80); + + *d++ = UTF8_EIGHT_BIT_HI(uv); + *d++ = UTF8_EIGHT_BIT_LO(uv); } } *d = '\0';