From 647552e493529551c01cb764b26ee57cfc5a9eb7 Mon Sep 17 00:00:00 2001 From: Pavel Charvat Date: Fri, 23 Nov 2007 10:38:03 +0100 Subject: [PATCH] ucwlib: Added a function for checking "regular" unicode values. --- lib/unicode.h | 11 +++++++++++ 1 file changed, 11 insertions(+) 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); -- 2.39.2