1 #include <u.h> 2 #include <libc.h> 3 4 char* utfrune(char * s,long c)5utfrune(char *s, long c) 6 { 7 long c1; 8 Rune r; 9 int n; 10 11 if(c < Runesync) /* not part of utf sequence */ 12 return strchr(s, c); 13 14 for(;;) { 15 c1 = *(uchar*)s; 16 if(c1 < Runeself) { /* one byte rune */ 17 if(c1 == 0) 18 return 0; 19 if(c1 == c) 20 return s; 21 s++; 22 continue; 23 } 24 n = chartorune(&r, s); 25 if(r == c) 26 return s; 27 s += n; 28 } 29 return 0; 30 } 31