branch update for HEAD-2003021201
[reactos.git] / lib / msvcrt / mbstring / mbclen.c
1 #include <msvcrt/mbstring.h>
2 #include <msvcrt/stdlib.h>
3
4
5 size_t _mbclen(const unsigned char *s)
6 {
7         return (_ismbblead(*s>>8) && _ismbbtrail(*s&0x00FF)) ? 2 : 1;
8 }
9
10 size_t _mbclen2(const unsigned int s)
11 {
12         return (_ismbblead(s>>8) && _ismbbtrail(s&0x00FF)) ? 2 : 1;
13 }
14
15 // assume MB_CUR_MAX == 2
16 int mblen( const char *s, size_t count )
17 {
18         size_t l;
19         if ( s == NULL )
20                 return 0;
21
22         l =  _mbclen(s);
23         if ( l < count )
24                 return -1;
25         return l;
26 }