1 #include <mbstring.h> 2 3 /* 4 * @implemented 5 */ _mbsnccnt(const unsigned char * str,size_t n)6size_t _mbsnccnt(const unsigned char *str, size_t n) 7 { 8 unsigned char *s = (unsigned char *)str; 9 size_t cnt = 0; 10 while(*s != 0 && n > 0) { 11 if (_ismbblead(*s) ) 12 s++; 13 else 14 n--; 15 s++; 16 cnt++; 17 } 18 19 return cnt; 20 } 21 22 /* 23 * @implemented 24 */ _mbsnbcnt(const unsigned char * str,size_t n)25size_t _mbsnbcnt(const unsigned char *str, size_t n) 26 { 27 unsigned char *s = (unsigned char *)str; 28 while(*s != 0 && n > 0) { 29 if (!_ismbblead(*s) ) 30 n--; 31 s++; 32 } 33 34 return (size_t)(s - str); 35 } 36