From: Pavel Charvat Date: Fri, 23 Nov 2007 09:38:03 +0000 (+0100) Subject: ucwlib: Added a function for checking "regular" unicode values. X-Git-Tag: holmes-import~499^2~2 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=647552e493529551c01cb764b26ee57cfc5a9eb7;p=libucw.git ucwlib: Added a function for checking "regular" unicode values. --- diff --git a/lib/unicode.h b/lib/unicode.h index 52ea5e68..8f8fe0e2 100644 --- a/lib/unicode.h +++ b/lib/unicode.h @@ -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);