]> mj.ucw.cz Git - libucw.git/blobdiff - lib/index.h
Defined a GET_TAGGED_CHAR macro to read our internal representation
[libucw.git] / lib / index.h
index 6394b65cfa2ed55833a68aecc33ea3e04c28f1fd..70a8186d7e2eaf6078811ba45cd4ff4264acba34 100644 (file)
@@ -62,3 +62,23 @@ struct fingerprint {
 };
 
 void fingerprint(byte *string, struct fingerprint *fp);
+
+/* Reading of tagged text (Unicode values, tags mapped to 0x80000000 and higher) */
+
+#define GET_TAGGED_CHAR(p,u) do {                              \
+  u = *p;                                                      \
+  if (u >= 0xc0)                                               \
+    GET_UTF8(p,u);                                             \
+  else if (u >= 0x80)                                          \
+    {                                                          \
+      p++;                                                     \
+      if (u >= 0xb0)                                           \
+       u += 0x80020000;                                        \
+      else if (u >= 0xa0)                                      \
+       u = 0x80010000 + ((u & 0x0f) << 6) + (*p++ & 0x3f);     \
+      else                                                     \
+       u += 0x80000000;                                        \
+    }                                                          \
+  else                                                         \
+    p++;                                                       \
+} while (0)