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