diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2001-02-18 18:41:33 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-02-18 18:41:33 +0000 |
commit | 90f44359bb7541a575a1666f79be58a556605cf6 (patch) | |
tree | b3a91266cabf50b1fb765a7db7afcd2b9ca9d2eb /utf8.c | |
parent | a7312d381f9e9a4b4701b842c00b370d3e74866b (diff) | |
download | perl-90f44359bb7541a575a1666f79be58a556605cf6.tar.gz |
UTF-8 tweaks.
p4raw-id: //depot/perl@8827
Diffstat (limited to 'utf8.c')
-rw-r--r-- | utf8.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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'; |