1 #include <mbstring.h> 2 3 4 size_t _mbclen2(const unsigned int s); 5 unsigned int _mbbtoupper(unsigned int c); 6 7 8 /* 9 * @implemented 10 */ _mbsnicmp(const unsigned char * s1,const unsigned char * s2,size_t n)11int _mbsnicmp(const unsigned char *s1, const unsigned char *s2, size_t n) 12 { 13 if (n == 0) 14 return 0; 15 do { 16 if (_mbbtoupper(*s1) != _mbbtoupper(*s2)) 17 return _mbbtoupper(*(unsigned const char *)s1) - _mbbtoupper(*(unsigned const char *)s2); 18 s1 += _mbclen2(*s1); 19 s2 += _mbclen2(*s2); 20 21 if (*s1 == 0) 22 break; 23 if (!_ismbblead(*s1)) 24 n--; 25 } while (n > 0); 26 return 0; 27 } 28 29 /* 30 * @implemented 31 */ _mbsnbicmp(const unsigned char * s1,const unsigned char * s2,size_t n)32int _mbsnbicmp(const unsigned char *s1, const unsigned char *s2, size_t n) 33 { 34 if (n == 0) 35 return 0; 36 do { 37 if (_mbbtoupper(*s1) != _mbbtoupper(*s2)) 38 return _mbbtoupper(*(unsigned const char *)s1) - _mbbtoupper(*(unsigned const char *)s2); 39 s1 += _mbclen2(*s1); 40 s2 += _mbclen2(*s2); 41 42 if (*s1 == 0) 43 break; 44 n--; 45 } while (n > 0); 46 return 0; 47 } 48