ReactOS  0.4.14-dev-815-ge410a12
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 {
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  if(!locinfo->lc_codepage)
29  tmpdst = (unsigned char)*str;
30  else if(!MultiByteToWideChar(locinfo->lc_codepage, 0, str, n, &tmpdst, 1))
31  return -1;
32  if(dst)
33  *dst = tmpdst;
34  /* return the number of bytes from src that have been used */
35  if(!*str)
36  return 0;
37  if(n >= 2 && _isleadbyte_l((unsigned char)*str, locale) && str[1])
38  return 2;
39  return 1;
40 }
41 
42 /*********************************************************************
43  * mbtowc(MSVCRT.@)
44  */
45 int CDECL mbtowc(wchar_t *dst, const char* str, size_t n)
46 {
47  return _mbtowc_l(dst, str, n, NULL);
48 }
GLdouble n
Definition: glext.h:7729
struct MSVCRT_threadlocaleinfostruct * MSVCRT_pthreadlocinfo
Definition: msvcrt.h:147
Definition: _locale.h:75
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
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
int CDECL _mbtowc_l(wchar_t *dst, const char *str, size_t n, _locale_t locale)
Definition: mbtowc.c:16
int CDECL mbtowc(wchar_t *dst, const char *str, size_t n)
Definition: mbtowc.c:45
#define CDECL
Definition: compat.h:21
GLenum GLenum dst
Definition: glext.h:6340
#define MultiByteToWideChar
Definition: compat.h:100
_Check_return_ _CRTIMP int __cdecl _isleadbyte_l(_In_ int _C, _In_opt_ _locale_t _Locale)