]> mj.ucw.cz Git - libucw.git/commitdiff
ucwlib: Added a function for checking "regular" unicode values.
authorPavel Charvat <pavel.charvat@netcentrum.cz>
Fri, 23 Nov 2007 09:38:03 +0000 (10:38 +0100)
committerPavel Charvat <pavel.charvat@netcentrum.cz>
Fri, 23 Nov 2007 09:38:03 +0000 (10:38 +0100)
lib/unicode.h

index 52ea5e687510c4ad1fdbefe6d602c30d5606a4b6..8f8fe0e21e9ae9fc6c267ab4be23c1152a24766d 100644 (file)
@@ -208,6 +208,17 @@ utf8_encoding_len(uns c)
   return 6;
 }
 
+static uns
+unicode_sanitize_char(uns u)
+{
+  if (u >= 0x10000 ||                  // We don't accept anything outside the basic plane
+      u >= 0xd800 && u < 0xf900 ||     // neither we do surrogates
+      u >= 0x80 && u < 0xa0 ||         // nor latin-1 control chars
+      u < 0x20)
+    return UNI_REPLACEMENT;
+  return u;
+}
+
 /* unicode-utf8.c */
 
 uns utf8_strlen(const byte *str);