summaryrefslogtreecommitdiff
path: root/utf8.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-02-18 18:41:33 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-02-18 18:41:33 +0000
commit90f44359bb7541a575a1666f79be58a556605cf6 (patch)
treeb3a91266cabf50b1fb765a7db7afcd2b9ca9d2eb /utf8.c
parenta7312d381f9e9a4b4701b842c00b370d3e74866b (diff)
downloadperl-90f44359bb7541a575a1666f79be58a556605cf6.tar.gz
UTF-8 tweaks.
p4raw-id: //depot/perl@8827
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/utf8.c b/utf8.c
index a36cc7420b..918b669e13 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';