ReactOS 0.4.16-dev-300-g2aadf2e
mbclen.c File Reference
#include <precomp.h>
#include <mbstring.h>
Include dependency graph for mbclen.c:

Go to the source code of this file.

Functions

size_t _mbclen (const unsigned char *s)
 
size_t _mbclen2 (const unsigned int s)
 
int mblen (const char *str, size_t size)
 
size_t __cdecl mbrlen (const char *str, size_t len, mbstate_t *state)
 

Function Documentation

◆ _mbclen()

size_t _mbclen ( const unsigned char s)

Definition at line 18 of file mbclen.c.

19{
20 return _ismbblead(*s) ? 2 : 1;
21}
GLdouble s
Definition: gl.h:2039
int __cdecl _ismbblead(unsigned int)
Definition: ismblead.c:20

◆ _mbclen2()

size_t _mbclen2 ( const unsigned int  s)

Definition at line 23 of file mbclen.c.

24{
25 return (_ismbblead(s>>8) && _ismbbtrail(s&0x00FF)) ? 2 : 1;
26}
_Check_return_ _CRTIMP int __cdecl _ismbbtrail(_In_ unsigned int _C)

Referenced by _mbsnbcat(), _mbsnbicmp(), _mbsnbset(), _mbsnicmp(), _mbsnset(), and _mbsset().

◆ mblen()

int mblen ( const char str,
size_t  size 
)

Definition at line 33 of file mbclen.c.

34{
35 if (str && *str && size)
36 {
37 return !isleadbyte((unsigned char)*str) ? 1 : (size>1 ? 2 : -1);
38 }
39 return 0;
40}
GLsizeiptr size
Definition: glext.h:5919
#define isleadbyte(_c)
Definition: wchar.h:598
const WCHAR * str

◆ mbrlen()

size_t __cdecl mbrlen ( const char str,
size_t  len,
mbstate_t state 
)

Definition at line 42 of file mbclen.c.

43{
44 mbstate_t s = (state ? *state : 0);
45 size_t ret;
46
47 if(!len || !str || !*str)
48 return 0;
49
50 if(get_locinfo()->mb_cur_max == 1) {
51 return 1;
52 }else if(!s && isleadbyte((unsigned char)*str)) {
53 if(len == 1) {
54 s = (unsigned char)*str;
55 ret = -2;
56 }else {
57 ret = 2;
58 }
59 }else if(!s) {
60 ret = 1;
61 }else {
62 s = 0;
63 ret = 2;
64 }
65
66 if(state)
67 *state = s;
68 return ret;
69}
static int state
Definition: maze.c:121
unsigned char
Definition: typeof.h:29
GLenum GLsizei len
Definition: glext.h:6722
int ret
#define get_locinfo()
Definition: winesup.h:25