From b35c2205c744eaf557d64280b5fe98c2cb86f4ed Mon Sep 17 00:00:00 2001 From: Pavel Charvat Date: Mon, 25 Jun 2007 16:39:40 +0200 Subject: [PATCH] noted that utf8_{put/get} supports only a subset of the Unicode range --- lib/unicode.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/unicode.h b/lib/unicode.h index 685e9f81..12c0fd04 100644 --- a/lib/unicode.h +++ b/lib/unicode.h @@ -15,6 +15,8 @@ #define UNI_REPLACEMENT 0xfffc +/* Encode a character from the basic character set [0, 0xFFFF] + * (subset of the formal Unicode range); up to 3 bytes needed (RFC2279) */ static inline byte * utf8_put(byte *p, uns u) { @@ -35,6 +37,7 @@ utf8_put(byte *p, uns u) return p; } +/* Encode a value from the range [0, 0x7FFFFFFF]; up to 6 bytes needed (RFC2279) */ static inline byte * utf8_32_put(byte *p, uns u) { @@ -76,6 +79,8 @@ put1: *p++ = 0x80 | (u & 0x3f); #define UTF8_GET_NEXT if (unlikely((*p & 0xc0) != 0x80)) goto bad; u = (u << 6) | (*p++ & 0x3f) +/* Decode a character from the basic character set [0, 0xFFFF] + * or return UNI_REPLACEMENT if the encoding has been corrupted */ static inline byte * utf8_get(const byte *p, uns *uu) { @@ -105,6 +110,8 @@ utf8_get(const byte *p, uns *uu) return (byte *)p; } +/* Decode a value from the range [0, 0x7FFFFFFF] + * or return UNI_REPLACEMENT if the encoding has been corrupted */ static inline byte * utf8_32_get(const byte *p, uns *uu) { -- 2.39.2