ReactOS  0.4.15-dev-1397-g19779b3
mbstowcs.c File Reference
#include <precomp.h>
Include dependency graph for mbstowcs.c:

Go to the source code of this file.

Functions

size_t CDECL _mbstowcs_l (wchar_t *wcstr, const char *mbstr, size_t count, _locale_t locale)
 
size_t mbstowcs (wchar_t *widechar, const char *multibyte, size_t number)
 

Function Documentation

◆ _mbstowcs_l()

size_t CDECL _mbstowcs_l ( wchar_t wcstr,
const char mbstr,
size_t  count,
_locale_t  locale 
)

Definition at line 6 of file mbstowcs.c.

8 {
10  size_t i, size;
11 
12  if(!mbstr) {
14  return -1;
15  }
16 
17  if(!locale)
18  locinfo = get_locinfo();
19  else
20  locinfo = ((MSVCRT__locale_t)locale)->locinfo;
21 
22  if(!locinfo->lc_codepage) {
23  if(!wcstr)
24  return strlen(mbstr);
25 
26  for(i=0; i<count; i++) {
27  wcstr[i] = (unsigned char)mbstr[i];
28  if(!wcstr[i]) break;
29  }
30  return i;
31  }
32 
33  /* Ignore count parameter */
34  if(!wcstr)
35  return MultiByteToWideChar(locinfo->lc_codepage, 0, mbstr, -1, NULL, 0)-1;
36 
37  for(i=0, size=0; i<count; i++) {
38  if(mbstr[size] == '\0')
39  break;
40 
41  size += (_isleadbyte_l((unsigned char)mbstr[size], locale) ? 2 : 1);
42  }
43 
44  if(size) {
45  size = MultiByteToWideChar(locinfo->lc_codepage, 0,
46  mbstr, size, wcstr, count);
47  if(!size) {
48  if(count) wcstr[0] = '\0';
50  return -1;
51  }
52  }
53 
54  if(size<count)
55  wcstr[size] = '\0';
56 
57  return size;
58 }
errno_t __cdecl _set_errno(_In_ int _Value)
#define EILSEQ
Definition: errno.h:97
struct MSVCRT_localeinfo_struct * MSVCRT__locale_t
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
Definition: arc.h:39
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: _locale.h:75
unsigned char
Definition: typeof.h:29
#define get_locinfo()
Definition: winesup.h:25
GLsizeiptr size
Definition: glext.h:5919
else locinfo
Definition: scanf.h:159
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
_Check_return_ _CRTIMP int __cdecl _isleadbyte_l(_In_ int _C, _In_opt_ _locale_t _Locale)

Referenced by mbstowcs().

◆ mbstowcs()

size_t mbstowcs ( wchar_t widechar,
const char multibyte,
size_t  number 
)

Definition at line 63 of file mbstowcs.c.

64 {
65  return _mbstowcs_l(widechar, multibyte, number, NULL);
66 }
size_t CDECL _mbstowcs_l(wchar_t *wcstr, const char *mbstr, size_t count, _locale_t locale)
Definition: mbstowcs.c:6
static size_t double number
Definition: printf.c:69
#define NULL
Definition: types.h:112

Referenced by START_TEST().