X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=charset%2Fstrlen.c;h=1fb0f7562a46657cb34076357945145cb4f54494;hb=ddb01cbb4eb8431b042918438e6543003851a87f;hp=723b6624ec7f7886c83fab1a65da708cca525386;hpb=ac9212c1d03bd23f6322bef39a4a0384b5afcc5d;p=libucw.git diff --git a/charset/strlen.c b/charset/strlen.c index 723b6624..1fb0f756 100644 --- a/charset/strlen.c +++ b/charset/strlen.c @@ -1,10 +1,15 @@ /* * 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. */ -#include "unicode.h" +#include "lib/lib.h" +#include "charset/unicode.h" uns Ustrlen(word *w) @@ -15,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; +}