summaryrefslogtreecommitdiff
path: root/utf8.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>2000-02-07 06:26:30 +0000
committerGurusamy Sarathy <gsar@cpan.org>2000-02-07 06:26:30 +0000
commit3c77ea2bace63b1ad27d15a6366cb938bdd158cb (patch)
tree4f7833e63f5047ba704288bc8311e27b7a7481f0 /utf8.c
parent7fa2f4f15785dd46abca32ba3f3cb3aabf0263dd (diff)
downloadperl-3c77ea2bace63b1ad27d15a6366cb938bdd158cb.tar.gz
allow 64-bit utf8-encoded integers (from Ilya Zakharevich)
p4raw-id: //depot/perl@5011
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/utf8.c b/utf8.c
index 3d9caf9337..b14fafec60 100644
--- a/utf8.c
+++ b/utf8.c
@@ -84,6 +84,11 @@ Perl_uv_to_utf8(pTHX_ U8 *d, UV uv)
#ifdef HAS_QUAD
{
*d++ = 0xff; /* Can't match U+FFFE! */
+ *d++ = 0x80; /* 6 Reserved bits */
+ *d++ = (((uv >> 60) & 0x0f) | 0x80); /* 2 Reserved bits */
+ *d++ = (((uv >> 54) & 0x3f) | 0x80);
+ *d++ = (((uv >> 48) & 0x3f) | 0x80);
+ *d++ = (((uv >> 42) & 0x3f) | 0x80);
*d++ = (((uv >> 36) & 0x3f) | 0x80);
*d++ = (((uv >> 30) & 0x3f) | 0x80);
*d++ = (((uv >> 24) & 0x3f) | 0x80);
@@ -120,8 +125,8 @@ Perl_utf8_to_uv(pTHX_ U8* s, I32* retlen)
else if (!(uv & 0x08)) { len = 4; uv &= 0x07; }
else if (!(uv & 0x04)) { len = 5; uv &= 0x03; }
else if (!(uv & 0x02)) { len = 6; uv &= 0x01; }
- else if (!(uv & 0x01)) { len = 7; uv &= 0x00; }
- else len = 8; /* whoa! */
+ else if (!(uv & 0x01)) { len = 7; uv = 0; }
+ else { len = 13; uv = 0; } /* whoa! */
if (retlen)
*retlen = len;