]> mj.ucw.cz Git - libucw.git/blobdiff - lib/unicode.h
Another minor optimization: Added AddRadixBits.
[libucw.git] / lib / unicode.h
index 685e9f81a09646ac0e42d75c5abcc26da72981f4..52ea5e687510c4ad1fdbefe6d602c30d5606a4b6 100644 (file)
@@ -15,6 +15,8 @@
 
 #define UNI_REPLACEMENT 0xfffc
 
 
 #define UNI_REPLACEMENT 0xfffc
 
+/* Encode a character from the basic multilingual plane [0, 0xFFFF]
+ * (subset of Unicode 4.0); up to 3 bytes needed (RFC2279) */
 static inline byte *
 utf8_put(byte *p, uns u)
 {
 static inline byte *
 utf8_put(byte *p, uns u)
 {
@@ -35,6 +37,8 @@ utf8_put(byte *p, uns u)
   return p;
 }
 
   return p;
 }
 
+/* Encode a value from the range [0, 0x7FFFFFFF];
+ * (superset of Unicode 4.0) up to 6 bytes needed (RFC2279) */
 static inline byte *
 utf8_32_put(byte *p, uns u)
 {
 static inline byte *
 utf8_32_put(byte *p, uns u)
 {
@@ -76,6 +80,8 @@ put1: *p++ = 0x80 | (u & 0x3f);
 
 #define UTF8_GET_NEXT if (unlikely((*p & 0xc0) != 0x80)) goto bad; u = (u << 6) | (*p++ & 0x3f)
 
 
 #define UTF8_GET_NEXT if (unlikely((*p & 0xc0) != 0x80)) goto bad; u = (u << 6) | (*p++ & 0x3f)
 
+/* Decode a character from the basic multilingual plane [0, 0xFFFF]
+ * or return UNI_REPLACEMENT if the encoding has been corrupted */
 static inline byte *
 utf8_get(const byte *p, uns *uu)
 {
 static inline byte *
 utf8_get(const byte *p, uns *uu)
 {
@@ -105,6 +111,8 @@ utf8_get(const byte *p, uns *uu)
   return (byte *)p;
 }
 
   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)
 {
 static inline byte *
 utf8_32_get(const byte *p, uns *uu)
 {
@@ -204,6 +212,5 @@ utf8_encoding_len(uns c)
 
 uns utf8_strlen(const byte *str);
 uns utf8_strnlen(const byte *str, uns n);
 
 uns utf8_strlen(const byte *str);
 uns utf8_strnlen(const byte *str, uns n);
-uns utf8_check(const byte *str);
 
 #endif
 
 #endif