2 * UCW Library -- UTF-8 Functions
4 * (c) 1997--2004 Martin Mares <mj@ucw.cz>
5 * (c) 2003 Robert Spalek <robert@ucw.cz>
7 * This software may be freely distributed and used according to the terms
8 * of the GNU Lesser General Public License.
12 #include "lib/unicode.h"
15 utf8_strlen(const byte *str)
27 utf8_strnlen(const byte *str, uns n)
30 const byte *end = str + n;
40 utf8_check(const byte *s)
42 #define UTF8_CHECK_NEXT if (unlikely((*s & 0xc0) != 0x80)) goto bad; s++
48 else if (unlikely(u < 0xc0))
57 else if (likely(u < 0xf0))
71 int main(int argc, char **argv)
74 if (argc > 1 && !strncmp(argv[1], "get", 3))
76 int f32 = !strcmp(argv[1], "get32");
79 while (scanf("%x", &u) == 1)
95 else if (argc > 1 && !strncmp(argv[1], "put", 3))
98 int f32 = !strcmp(argv[1], "put32");
99 while (scanf("%x", &u) == 1)