]> mj.ucw.cz Git - libucw.git/blobdiff - charset/strlen.c
Renamed tabgen to gen-charconv.
[libucw.git] / charset / strlen.c
index 1aad35ccdd23ed0fc6d57622e417d17fcf2d8cb8..1fb0f7562a46657cb34076357945145cb4f54494 100644 (file)
@@ -1,7 +1,11 @@
 /*
  *     The UniCode Library -- String Length
  *
- *     (c) 1997 Martin Mares <mj@ucw.cz>
+ *     (c) 1997--2003 Martin Mares <mj@ucw.cz>
+ *     (c) 2003 Robert Spalek <robert@ucw.cz>
+ *
+ *     This software may be freely distributed and used according to the terms
+ *     of the GNU Lesser General Public License.
  */
 
 #include "lib/lib.h"
@@ -16,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;
+}