1 /* $MirOS: src/lib/libc/i18n/mbslen.c,v 1.3 2007/02/02 21:06:21 tg Exp $ */
2
3 /*-
4 * Copyright (c) 2006
5 * Thorsten Glaser <tg@mirbsd.de>
6 *
7 * Provided that these terms and disclaimer and all copyright notices
8 * are retained or reproduced in an accompanying document, permission
9 * is granted to deal in this work without restriction, including un-
10 * limited rights to use, publicly perform, distribute, sell, modify,
11 * merge, give away, or sublicence.
12 *
13 * Advertising materials mentioning features or use of this work must
14 * display the following acknowledgement:
15 * This product includes material provided by Thorsten Glaser.
16 *
17 * This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to
18 * the utmost extent permitted by applicable law, neither express nor
19 * implied; without malicious intent or gross negligence. In no event
20 * may a licensor, author or contributor be held liable for indirect,
21 * direct, other damage, loss, or other issues arising in any way out
22 * of dealing in the work, even if advised of the possibility of such
23 * damage or existence of a defect, except proven that it results out
24 * of said person's immediate fault when using the work as intended.
25 */
26
27 #include <wchar.h>
28
29 __RCSID("$MirOS: src/lib/libc/i18n/mbslen.c,v 1.3 2007/02/02 21:06:21 tg Exp $");
30
31 #undef mbslen
32 size_t
mbslen(const char * s)33 mbslen(const char *s)
34 {
35 size_t num = 0;
36 register uint8_t c;
37
38 while ((c = *s++))
39 if ((c & 0xC0) != 0x80)
40 ++num;
41 return (num);
42 }
43