/*
* 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
utf8_strlen(byte *str)
{
uns len = 0;
- while (1)
- {
- uns c;
- GET_UTF8(str, c);
- if (!c)
- return len;
- len++;
- }
+ 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;
+}
/*
* The UniCode Library
*
- * (c) 1997 Martin Mares <mj@ucw.cz>
+ * (c) 1997--2003 Martin Mares <mj@ucw.cz>
*
* This software may be freely distributed and used according to the terms
* of the GNU Lesser General Public License.
byte *static_ucs2_to_utf8(word *);
uns Ustrlen(word *);
uns utf8_strlen(byte *str);
+uns utf8_strnlen(byte *str, uns n);
#endif