ReactOS
0.4.16-dev-136-g52192f1
mbrtowc.c
Go to the documentation of this file.
1
/*
2
* msvcrt.dll mbcs functions
3
*
4
* Copyright 1999 Alexandre Julliard
5
* Copyright 2000 Jon Griffths
6
*
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2.1 of the License, or (at your option) any later version.
11
*
12
* This library is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
16
*
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this library; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20
*/
21
22
#include <precomp.h>
23
#include <locale.h>
24
25
/*********************************************************************
26
* mbrtowc(MSVCRT.@)
27
*/
28
size_t
CDECL
mbrtowc
(
wchar_t
*
dst
,
const
char
*
str
,
29
size_t
n
,
mbstate_t
*
state
)
30
{
31
mbstate_t
s
= (
state
? *
state
: 0);
32
char
tmpstr[2];
33
int
len
= 0;
34
35
if
(
dst
)
36
*
dst
= 0;
37
38
if
(!
n
|| !
str
|| !*
str
)
39
return
0;
40
41
if
(
___mb_cur_max_func
() == 1) {
42
tmpstr[
len
++] = *
str
;
43
}
else
if
(!
s
&&
isleadbyte
((
unsigned
char
)*
str
)) {
44
if
(
n
== 1) {
45
s
= (
unsigned
char
)*
str
;
46
len
= -2;
47
}
else
{
48
tmpstr[0] =
str
[0];
49
tmpstr[1] =
str
[1];
50
len
= 2;
51
}
52
}
else
if
(!
s
) {
53
tmpstr[
len
++] = *
str
;
54
}
else
{
55
tmpstr[0] =
s
;
56
tmpstr[1] = *
str
;
57
len
= 2;
58
s
= 0;
59
}
60
61
if
(
len
> 0) {
62
if
(!
MultiByteToWideChar
(
___lc_codepage_func
(), 0, tmpstr,
len
,
dst
,
dst
? 1 : 0))
63
len
= -1;
64
}
65
66
if
(
state
)
67
*
state
=
s
;
68
return
len
;
69
}
state
static int state
Definition:
maze.c:121
CDECL
#define CDECL
Definition:
compat.h:29
MultiByteToWideChar
#define MultiByteToWideChar
Definition:
compat.h:110
char
unsigned char
Definition:
typeof.h:29
s
GLdouble s
Definition:
gl.h:2039
n
GLdouble n
Definition:
glext.h:7729
dst
GLenum GLenum dst
Definition:
glext.h:6340
len
GLenum GLsizei len
Definition:
glext.h:6722
___mb_cur_max_func
#define ___mb_cur_max_func()
Definition:
ctype.h:636
___lc_codepage_func
_CRTIMP unsigned int __cdecl ___lc_codepage_func(void)
Definition:
locale.c:627
isleadbyte
#define isleadbyte(_c)
Definition:
wchar.h:596
str
const WCHAR * str
Definition:
rpc_transport.c:2724
__mbstate_t
Definition:
_sunprocc.h:145
mbrtowc
#define mbrtowc(wp, cp, len, sp)
Definition:
wchar.h:158
sdk
lib
crt
wstring
mbrtowc.c
Generated on Tue Oct 15 2024 06:13:19 for ReactOS by
1.9.6