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