ReactOS 0.4.16-dev-329-g9223134
mbstowcs.c
Go to the documentation of this file.
1#include <precomp.h>
2
3/*********************************************************************
4 * _mbstowcs_l (MSVCRT.@)
5 */
6size_t CDECL _mbstowcs_l(wchar_t *wcstr, const char *mbstr,
7 size_t count, _locale_t locale)
8{
10 size_t i, size;
11
12 if(!mbstr) {
14 return -1;
15 }
16
17 if(!locale)
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}
59
60/*
61 * @implemented
62 */
63size_t mbstowcs (wchar_t *widechar, const char *multibyte, size_t number)
64{
65 return _mbstowcs_l(widechar, multibyte, number, NULL);
66}
#define EINVAL
Definition: acclib.h:90
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
Definition: _locale.h:75
#define NULL
Definition: types.h:112
#define CDECL
Definition: compat.h:29
#define MultiByteToWideChar
Definition: compat.h:110
unsigned char
Definition: typeof.h:29
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
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
_Check_return_ _CRTIMP int __cdecl _isleadbyte_l(_In_ int _C, _In_opt_ _locale_t _Locale)
size_t __cdecl mbstowcs(_Out_writes_opt_z_(_MaxCount) wchar_t *_Dest, _In_z_ const char *_Source, _In_ size_t _MaxCount)
static unsigned int number
Definition: dsound.c:1479
struct MSVCRT_localeinfo_struct * MSVCRT__locale_t
else locinfo
Definition: scanf.h:159
errno_t __cdecl _set_errno(_In_ int _Value)
#define EILSEQ
Definition: errno.h:109
size_t CDECL _mbstowcs_l(wchar_t *wcstr, const char *mbstr, size_t count, _locale_t locale)
Definition: mbstowcs.c:6
#define get_locinfo()
Definition: winesup.h:25