From: Pavel Charvat Date: Mon, 25 Jun 2007 14:39:40 +0000 (+0200) Subject: noted that utf8_{put/get} supports only a subset of the Unicode range X-Git-Tag: holmes-import~506^2~59 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=b35c2205c744eaf557d64280b5fe98c2cb86f4ed;p=libucw.git noted that utf8_{put/get} supports only a subset of the Unicode range --- 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) {