X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=charset%2Fstrlen.c;h=1fb0f7562a46657cb34076357945145cb4f54494;hb=2b797fef8d8133e5b1cb40706aabc92718da40bd;hp=ae682db5efc5f426d4bda14f055e00acf0284ae6;hpb=49ed04e2e93a6a5b01058638224621d5c07db01c;p=libucw.git diff --git a/charset/strlen.c b/charset/strlen.c index ae682db5..1fb0f756 100644 --- a/charset/strlen.c +++ b/charset/strlen.c @@ -1,7 +1,8 @@ /* * The UniCode Library -- String Length * - * (c) 1997 Martin Mares + * (c) 1997--2003 Martin Mares + * (c) 2003 Robert Spalek * * This software may be freely distributed and used according to the terms * of the GNU Lesser General Public License. @@ -19,3 +20,28 @@ Ustrlen(word *w) z++; return z - w; } + +uns +utf8_strlen(byte *str) +{ + uns len = 0; + while (*str) + { + UTF8_SKIP(str); + len++; + } + return len; +} + +uns +utf8_strnlen(byte *str, uns n) +{ + uns len = 0; + byte *end = str + n; + while (str < end) + { + UTF8_SKIP(str); + len++; + } + return len; +}