ReactOS
0.4.16-dev-833-g4bc97ad
mbtowc.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/stdlib/mbtowc.c
5
* PURPOSE: Unknown
6
* PROGRAMER: Unknown
7
* UPDATE HISTORY:
8
* 25/11/05: Added license header
9
*/
10
11
#include <precomp.h>
12
13
/*********************************************************************
14
* _mbtowc_l(MSVCRT.@)
15
*/
16
int
CDECL
_mbtowc_l
(
wchar_t
*
dst
,
const
char
*
str
,
size_t
n
,
_locale_t
locale
)
17
{
18
MSVCRT_pthreadlocinfo
locinfo
;
19
wchar_t
tmpdst =
'\0'
;
20
21
if
(!
locale
)
22
locinfo
=
get_locinfo
();
23
else
24
locinfo
= (
MSVCRT_pthreadlocinfo
)(
locale
->locinfo);
25
26
if
(
n
<= 0 || !
str
)
27
return
0;
28
29
if
(!*
str
) {
30
if
(
dst
) *
dst
= 0;
31
return
0;
32
}
33
34
if
(!
locinfo
->lc_codepage) {
35
if
(
dst
) *
dst
= (
unsigned
char
)*
str
;
36
return
1;
37
}
38
if
(
n
>= 2 &&
_isleadbyte_l
((
unsigned
char
)*
str
,
locale
)) {
39
if
(!
MultiByteToWideChar
(
locinfo
->lc_codepage, 0,
str
, 2, &tmpdst, 1))
40
return
-1;
41
if
(
dst
) *
dst
= tmpdst;
42
return
2;
43
}
44
if
(!
MultiByteToWideChar
(
locinfo
->lc_codepage, 0,
str
, 1, &tmpdst, 1))
45
return
-1;
46
if
(
dst
) *
dst
= tmpdst;
47
return
1;
48
}
49
50
/*********************************************************************
51
* mbtowc(MSVCRT.@)
52
*/
53
int
CDECL
mbtowc
(
wchar_t
*
dst
,
const
char
*
str
,
size_t
n
)
54
{
55
return
_mbtowc_l
(
dst
,
str
,
n
,
NULL
);
56
}
locale
Definition:
_locale.h:75
_isleadbyte_l
#define _isleadbyte_l(_C, _L)
Definition:
corecrt_internal.h:1574
NULL
#define NULL
Definition:
types.h:112
CDECL
#define CDECL
Definition:
compat.h:29
MultiByteToWideChar
#define MultiByteToWideChar
Definition:
compat.h:110
char
unsigned char
Definition:
typeof.h:29
n
GLdouble n
Definition:
glext.h:7729
dst
GLenum GLenum dst
Definition:
glext.h:6340
MSVCRT_pthreadlocinfo
struct MSVCRT_threadlocaleinfostruct * MSVCRT_pthreadlocinfo
Definition:
msvcrt.h:147
str
const WCHAR * str
Definition:
rpc_transport.c:2724
locinfo
else locinfo
Definition:
scanf.h:159
_mbtowc_l
int CDECL _mbtowc_l(wchar_t *dst, const char *str, size_t n, _locale_t locale)
Definition:
mbtowc.c:16
MSVCRT_threadlocaleinfostruct
Definition:
msvcrt.h:111
localeinfo_struct
Definition:
corecrt.h:22
mbtowc
#define mbtowc(wp, cp, len)
Definition:
wchar.h:155
get_locinfo
#define get_locinfo()
Definition:
winesup.h:25
sdk
lib
crt
stdlib
mbtowc.c
Generated on Wed Mar 19 2025 06:15:13 for ReactOS by
1.9.6