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