]> mj.ucw.cz Git - libucw.git/commitdiff
added utf8_strlen()
authorRobert Spalek <robert@ucw.cz>
Thu, 13 Feb 2003 12:42:10 +0000 (12:42 +0000)
committerRobert Spalek <robert@ucw.cz>
Thu, 13 Feb 2003 12:42:10 +0000 (12:42 +0000)
charset/strlen.c
charset/unicode.h

index ae682db5efc5f426d4bda14f055e00acf0284ae6..39c1cb5bae1a44c39d1a79d1f7435889ab770dc5 100644 (file)
@@ -2,6 +2,7 @@
  *     The UniCode Library -- String Length
  *
  *     (c) 1997 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.
@@ -19,3 +20,18 @@ Ustrlen(word *w)
     z++;
   return z - w;
 }
+
+uns
+utf8_strlen(byte *str)
+{
+  uns len = 0;
+  while (1)
+  {
+    uns c;
+    GET_UTF8(str, c);
+    if (!c)
+      return len;
+    len++;
+  }
+}
+
index c0afc17abc9da1cb5c2e172385f7a272cd92de19..1e11e0f7a9315dd2637ac5f894a830d7d75bdf95 100644 (file)
@@ -118,5 +118,6 @@ uns ucs2_to_utf8(byte *, word *);
 uns utf8_to_ucs2(word *, byte *);
 byte *static_ucs2_to_utf8(word *);
 uns Ustrlen(word *);
+uns utf8_strlen(byte *str);
 
 #endif