xref: /plan9/sys/src/cmd/unix/drawterm/libc/utflen.c (revision 8ccd4a6360d974db7bd7bbd4f37e7018419ea908)
1 #include <u.h>
2 #include <libc.h>
3 
4 int
utflen(char * s)5 utflen(char *s)
6 {
7 	int c;
8 	long n;
9 	Rune rune;
10 
11 	n = 0;
12 	for(;;) {
13 		c = *(uchar*)s;
14 		if(c < Runeself) {
15 			if(c == 0)
16 				return n;
17 			s++;
18 		} else
19 			s += chartorune(&rune, s);
20 		n++;
21 	}
22 	return 0;
23 }
24