ReactOS 0.4.15-dev-7953-g1f49173
mbclen.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: lib/sdk/crt/mbstring/mbclen.c
5 * PURPOSE: Determines the length of a multi byte character
6 * PROGRAMERS:
7 * Copyright 1999 Alexandre Julliard
8 * Copyright 2000 Jon Griffths
9 *
10 */
11
12#include <precomp.h>
13#include <mbstring.h>
14
15/*
16 * @implemented
17 */
18size_t _mbclen(const unsigned char *s)
19{
20 return _ismbblead(*s) ? 2 : 1;
21}
22
23size_t _mbclen2(const unsigned int s)
24{
25 return (_ismbblead(s>>8) && _ismbbtrail(s&0x00FF)) ? 2 : 1;
26}
27
28/*
29 * assume MB_CUR_MAX == 2
30 *
31 * @implemented
32 */
33int mblen( const char *str, size_t size )
34{
35 if (str && *str && size)
36 {
37 return !isleadbyte((unsigned char)*str) ? 1 : (size>1 ? 2 : -1);
38 }
39 return 0;
40}
41
42size_t __cdecl mbrlen(const char *str, size_t len, mbstate_t *state)
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}
70
#define __cdecl
Definition: accygwin.h:79
static int state
Definition: maze.c:121
unsigned char
Definition: typeof.h:29
GLdouble s
Definition: gl.h:2039
GLsizeiptr size
Definition: glext.h:5919
GLenum GLsizei len
Definition: glext.h:6722
#define isleadbyte(_c)
Definition: wchar.h:596
size_t _mbclen(const unsigned char *s)
Definition: mbclen.c:18
size_t _mbclen2(const unsigned int s)
Definition: mbclen.c:23
int mblen(const char *str, size_t size)
Definition: mbclen.c:33
size_t __cdecl mbrlen(const char *str, size_t len, mbstate_t *state)
Definition: mbclen.c:42
_Check_return_ _CRTIMP int __cdecl _ismbbtrail(_In_ unsigned int _C)
int __cdecl _ismbblead(unsigned int)
Definition: ismblead.c:20
const WCHAR * str
int ret
#define get_locinfo()
Definition: winesup.h:25