X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Funicode-utf8.c;h=e4a33af8495f216bcbade228c55ce271a8f0f23c;hb=c5fbc7b75705d1f7a322ad73e6055284a3b94e73;hp=8c8ac1bdf0df9a2308de945df8a87d67d19fa85a;hpb=6ea963867ef0111a93cc4fd503ef5a067b764ccc;p=libucw.git diff --git a/lib/unicode-utf8.c b/lib/unicode-utf8.c index 8c8ac1bd..e4a33af8 100644 --- a/lib/unicode-utf8.c +++ b/lib/unicode-utf8.c @@ -12,7 +12,7 @@ #include "lib/unicode.h" uns -utf8_strlen(byte *str) +utf8_strlen(const byte *str) { uns len = 0; while (*str) @@ -24,10 +24,10 @@ utf8_strlen(byte *str) } uns -utf8_strnlen(byte *str, uns n) +utf8_strnlen(const byte *str, uns n) { uns len = 0; - byte *end = str + n; + const byte *end = str + n; while (str < end) { UTF8_SKIP(str); @@ -36,35 +36,6 @@ utf8_strnlen(byte *str, uns n) return len; } -uns -utf8_check(byte *s) -{ -#define UTF8_CHECK_NEXT if (unlikely((*s & 0xc0) != 0x80)) goto bad; s++ - while (*s) - { - uns u = *s++; - if (u < 0x80) - ; - else if (unlikely(u < 0xc0)) - { -bad: - return 0; - } - else if (u < 0xe0) - { - UTF8_CHECK_NEXT; - } - else if (likely(u < 0xf0)) - { - UTF8_CHECK_NEXT; - UTF8_CHECK_NEXT; - } - else - goto bad; - } - return 1; -} - #ifdef TEST #include #include