ReactOS  0.4.15-dev-2522-g9e0a3cd
mbtowc.c File Reference
#include <precomp.h>
Include dependency graph for mbtowc.c:

Go to the source code of this file.

Functions

int CDECL _mbtowc_l (wchar_t *dst, const char *str, size_t n, _locale_t locale)
 
int CDECL mbtowc (wchar_t *dst, const char *str, size_t n)
 

Function Documentation

◆ _mbtowc_l()

int CDECL _mbtowc_l ( wchar_t dst,
const char str,
size_t  n,
_locale_t  locale 
)

Definition at line 16 of file mbtowc.c.

17 {
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 }
GLdouble n
Definition: glext.h:7729
struct MSVCRT_threadlocaleinfostruct * MSVCRT_pthreadlocinfo
Definition: msvcrt.h:147
Definition: _locale.h:75
const WCHAR * str
unsigned char
Definition: typeof.h:29
#define get_locinfo()
Definition: winesup.h:25
else locinfo
Definition: scanf.h:159
static const wchar_t void * locale
Definition: printf.c:79
GLenum GLenum dst
Definition: glext.h:6340
#define MultiByteToWideChar
Definition: compat.h:110
_Check_return_ _CRTIMP int __cdecl _isleadbyte_l(_In_ int _C, _In_opt_ _locale_t _Locale)

Referenced by mbtowc().

◆ mbtowc()

int CDECL mbtowc ( wchar_t dst,
const char str,
size_t  n 
)

Definition at line 53 of file mbtowc.c.

54 {
55  return _mbtowc_l(dst, str, n, NULL);
56 }
GLdouble n
Definition: glext.h:7729
const WCHAR * str
GLenum GLenum dst
Definition: glext.h:6340
#define NULL
Definition: types.h:112
int CDECL _mbtowc_l(wchar_t *dst, const char *str, size_t n, _locale_t locale)
Definition: mbtowc.c:16

Referenced by START_TEST().