xref: /inferno-os/libkern/utflen.c (revision 28272a0014d067c3b39985261782b42f361449d3)
1 #include "lib9.h"
2 
3 int
4 utflen(char *s)
5 {
6 	int c;
7 	long n;
8 	Rune rune;
9 
10 	n = 0;
11 	for(;;) {
12 		c = *(uchar*)s;
13 		if(c < Runeself) {
14 			if(c == 0)
15 				return n;
16 			s++;
17 		} else
18 			s += chartorune(&rune, s);
19 		n++;
20 	}
21 }
22