ReactOS 0.4.16-dev-2284-g3529151
wchar.h File Reference
#include <corecrt_wctype.h>
#include <corecrt_wdirect.h>
#include <corecrt_wio.h>
#include <corecrt_wprocess.h>
#include <corecrt_wstdio.h>
#include <corecrt_wstdlib.h>
#include <corecrt_wstring.h>
#include <corecrt_wtime.h>
#include <sys/stat.h>
Include dependency graph for wchar.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define WCHAR_MIN   0U
 
#define WCHAR_MAX   0xffffU
 
#define _WLOCALE_DEFINED
 

Typedefs

typedef int mbstate_t
 

Functions

_ACRTIMP wchar_t *__cdecl _wsetlocale (int, const wchar_t *)
 
wchar_t __cdecl btowc (int)
 
size_t __cdecl mbrlen (const char *, size_t, mbstate_t *)
 
size_t __cdecl mbrtowc (wchar_t *, const char *, size_t, mbstate_t *)
 
size_t __cdecl mbsrtowcs (wchar_t *, const char **, size_t, mbstate_t *)
 
size_t __cdecl wcrtomb (char *, wchar_t, mbstate_t *)
 
int __cdecl wcrtomb_s (size_t *, char *, size_t, wchar_t, mbstate_t *)
 
size_t __cdecl wcsrtombs (char *, const wchar_t **, size_t, mbstate_t *)
 
int __cdecl wctob (wint_t)
 
_ACRTIMP errno_t __cdecl wmemcpy_s (wchar_t *, size_t, const wchar_t *, size_t)
 
static wchar_twmemchr (const wchar_t *s, wchar_t c, size_t n)
 
static int wmemcmp (const wchar_t *s1, const wchar_t *s2, size_t n)
 
static wchar_t *__cdecl wmemcpy (wchar_t *dst, const wchar_t *src, size_t n)
 
static wchar_t *__cdecl wmemmove (wchar_t *dst, const wchar_t *src, size_t n)
 
static wchar_t *__cdecl wmemset (wchar_t *s, wchar_t c, size_t n)
 

Macro Definition Documentation

◆ _WLOCALE_DEFINED

#define _WLOCALE_DEFINED

Definition at line 33 of file wchar.h.

◆ WCHAR_MAX

#define WCHAR_MAX   0xffffU

Definition at line 27 of file wchar.h.

◆ WCHAR_MIN

#define WCHAR_MIN   0U

Definition at line 26 of file wchar.h.

Typedef Documentation

◆ mbstate_t

typedef int mbstate_t

Definition at line 30 of file wchar.h.

Function Documentation

◆ _wsetlocale()

_ACRTIMP wchar_t *__cdecl _wsetlocale ( int  category,
const wchar_t wlocale 
)

Definition at line 2097 of file locale.c.

2098{
2099 static wchar_t current_lc_all[MAX_LOCALE_LENGTH];
2100
2101 char *locale = NULL;
2102 const char *ret;
2103 size_t len;
2104
2105 if(wlocale) {
2106 len = wcstombs(NULL, wlocale, 0);
2107 if(len == -1)
2108 return NULL;
2109
2110 locale = malloc(++len);
2111 if(!locale)
2112 return NULL;
2113
2114 wcstombs(locale, wlocale, len);
2115 }
2116
2117 _lock_locales();
2119 free(locale);
2120
2121 if(ret && mbstowcs(current_lc_all, ret, MAX_LOCALE_LENGTH)==-1)
2122 ret = NULL;
2123
2125 return ret ? current_lc_all : NULL;
2126}
Definition: _locale.h:75
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
void CDECL _lock_locales(void)
Definition: locale.c:574
void CDECL _unlock_locales(void)
Definition: locale.c:582
#define MAX_LOCALE_LENGTH
Definition: locale.c:42
return ret
Definition: mutex.c:146
GLenum GLsizei len
Definition: glext.h:6722
wcstombs
Definition: stdlib.h:1013
mbstowcs
Definition: stdlib.h:925
#define setlocale(n, s)
Definition: locale.h:46

◆ btowc()

wchar_t __cdecl btowc ( int  c)

Definition at line 3211 of file mbcs.c.

3212{
3213 unsigned char letter = c;
3214 wchar_t ret;
3215
3216 if(c == EOF)
3217 return WEOF;
3218 if(!get_locinfo()->lc_codepage)
3219 return c & 255;
3220 if(!MultiByteToWideChar(get_locinfo()->lc_codepage,
3221 MB_ERR_INVALID_CHARS, (LPCSTR)&letter, 1, &ret, 1))
3222 return WEOF;
3223
3224 return ret;
3225}
#define MultiByteToWideChar
Definition: compat.h:110
#define WEOF
#define EOF
Definition: stdio.h:33
const GLubyte * c
Definition: glext.h:8905
#define MB_ERR_INVALID_CHARS
Definition: unicode.h:41
#define c
Definition: ke_i.h:80
#define get_locinfo()
Definition: winesup.h:25
const char * LPCSTR
Definition: xmlstorage.h:183

◆ mbrlen()

size_t __cdecl mbrlen ( const char str,
size_t  len,
mbstate_t state 
)

Definition at line 3100 of file mbcs.c.

3101{
3102 mbstate_t s = (state ? *state : 0);
3103 size_t ret;
3104
3105 if(!len || !str || !*str)
3106 return 0;
3107
3108 if(get_locinfo()->mb_cur_max == 1) {
3109 return 1;
3110 }else if(!s && isleadbyte((unsigned char)*str)) {
3111 if(len == 1) {
3112 s = (unsigned char)*str;
3113 ret = -2;
3114 }else {
3115 ret = 2;
3116 }
3117 }else if(!s) {
3118 ret = 1;
3119 }else {
3120 s = 0;
3121 ret = 2;
3122 }
3123
3124 if(state)
3125 *state = s;
3126 return ret;
3127}
static int state
Definition: maze.c:121
int mbstate_t
Definition: wchar.h:30
unsigned char
Definition: typeof.h:29
GLdouble s
Definition: gl.h:2039
const WCHAR * str
#define isleadbyte(_c)
Definition: wchar.h:598

◆ mbrtowc()

size_t __cdecl mbrtowc ( wchar_t dst,
const char str,
size_t  n,
mbstate_t state 
)

Definition at line 3230 of file mbcs.c.

3232{
3234 mbstate_t s = (state ? *state : 0);
3235 char tmpstr[2];
3236 int len = 0;
3237
3238 if(dst)
3239 *dst = 0;
3240
3241 if(!n || !str || !*str)
3242 return 0;
3243
3244 if(locinfo->mb_cur_max == 1) {
3245 tmpstr[len++] = *str;
3246 }else if(!s && isleadbyte((unsigned char)*str)) {
3247 if(n == 1) {
3248 s = (unsigned char)*str;
3249 len = -2;
3250 }else {
3251 tmpstr[0] = str[0];
3252 tmpstr[1] = str[1];
3253 len = 2;
3254 }
3255 }else if(!s) {
3256 tmpstr[len++] = *str;
3257 }else {
3258 tmpstr[0] = s;
3259 tmpstr[1] = *str;
3260 len = 2;
3261 s = 0;
3262 }
3263
3264 if(len > 0) {
3265 if(!MultiByteToWideChar(locinfo->lc_codepage, 0, tmpstr, len, dst, dst ? 1 : 0))
3266 len = -1;
3267 }
3268
3269 if(state)
3270 *state = s;
3271 return len;
3272}
else locinfo
Definition: scanf.h:225
GLdouble n
Definition: glext.h:7729
GLenum GLenum dst
Definition: glext.h:6340

◆ mbsrtowcs()

size_t __cdecl mbsrtowcs ( wchar_t wcstr,
const char **  pmbstr,
size_t  count,
mbstate_t state 
)

Definition at line 3430 of file mbcs.c.

3432{
3433 mbstate_t s = (state ? *state : 0);
3434 wchar_t tmpdst;
3435 size_t ret = 0;
3436 const char *p;
3437
3438 if(!MSVCRT_CHECK_PMT(pmbstr != NULL))
3439 return -1;
3440
3441 p = *pmbstr;
3442 while(!wcstr || count>ret) {
3443 int ch_len = mbrtowc(&tmpdst, p, 2, &s);
3444 if(wcstr)
3445 wcstr[ret] = tmpdst;
3446
3447 if(ch_len < 0) {
3448 return -1;
3449 }else if(ch_len == 0) {
3450 if(wcstr) *pmbstr = NULL;
3451 return ret;
3452 }
3453
3454 p += ch_len;
3455 ret++;
3456 }
3457
3458 if(wcstr) *pmbstr = p;
3459 return ret;
3460}
#define MSVCRT_CHECK_PMT(x)
Definition: msvcrt.h:378
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLfloat GLfloat p
Definition: glext.h:8902
#define mbrtowc(wp, cp, len, sp)
Definition: wchar.h:158

Referenced by mbsrtowcs_s().

◆ wcrtomb()

size_t __cdecl wcrtomb ( char dst,
wchar_t  ch,
mbstate_t s 
)

Definition at line 2211 of file wcs.c.

2212{
2213 if(s)
2214 *s = 0;
2215 return wctomb(dst, ch);
2216}
unsigned char ch[4][2]
Definition: console.c:118
#define wctomb
Definition: wctomb.c:31

◆ wcrtomb_s()

int __cdecl wcrtomb_s ( size_t len,
char mbchar,
size_t  size,
wchar_t  wch,
mbstate_t s 
)

Definition at line 2197 of file wcs.c.

2199{
2200 int ilen, ret;
2201
2202 if (s) *s = 0;
2203 ret = wctomb_s(&ilen, mbchar, size, wch);
2204 if (len) *len = ilen;
2205 return ret;
2206}
int CDECL wctomb_s(int *len, char *mbchar, size_t size, wchar_t wch)
Definition: wcs.c:2139
GLsizeiptr size
Definition: glext.h:5919

Referenced by wcrtomb().

◆ wcsrtombs()

size_t __cdecl wcsrtombs ( char mbstr,
const wchar_t **  wcstr,
size_t  count,
mbstate_t mbstate 
)

Definition at line 701 of file wcs.c.

703{
704 if(mbstate)
705 *mbstate = 0;
706
707 return wcsrtombs_l(mbstr, wcstr, count, NULL);
708}
static size_t wcsrtombs_l(char *mbstr, const wchar_t **wcstr, size_t count, _locale_t locale)
Definition: wcs.c:609

◆ wctob()

int __cdecl wctob ( wint_t  wchar)

Definition at line 2175 of file wcs.c.

2176{
2177 char out;
2178 BOOL error = FALSE;
2179 BOOL *perror;
2180 UINT codepage = get_locinfo()->lc_codepage;
2181
2182 perror = (codepage != CP_UTF8 ? &error : NULL);
2183
2184 if(!codepage) {
2185 if (wchar < 0xff)
2186 return (signed char)wchar;
2187 else
2188 return EOF;
2189 } else if(WideCharToMultiByte( codepage, 0, &wchar, 1, &out, 1, NULL, perror ) && !error)
2190 return (INT)out;
2191 return EOF;
2192}
#define FALSE
Definition: types.h:117
#define WideCharToMultiByte
Definition: compat.h:111
void CDECL perror(const char *str)
Definition: errno.c:337
unsigned int BOOL
Definition: ntddk_ex.h:94
#define error(str)
Definition: mkdosfs.c:1605
unsigned int UINT
Definition: ndis.h:50
#define CP_UTF8
Definition: nls.h:20
int32_t INT
Definition: typedefs.h:58
size_t const wchar_t const wchar
Definition: wcrtomb.cpp:53
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
int codepage
Definition: win_iconv.c:156

◆ wmemchr()

static wchar_t * wmemchr ( const wchar_t s,
wchar_t  c,
size_t  n 
)
inlinestatic

Definition at line 48 of file wchar.h.

49{
50 const wchar_t *end;
51 for (end = s + n; s < end; s++)
52 if (*s == c) return (wchar_t*)s;
53 return NULL;
54}
GLuint GLuint end
Definition: gl.h:1545

Referenced by add_local_oid_text_to_control(), get_slash_dir(), get_token(), InternetCrackUrlW(), is_domain_legal_for_cookie(), merge_paths(), and set_cookie().

◆ wmemcmp()

static int wmemcmp ( const wchar_t s1,
const wchar_t s2,
size_t  n 
)
inlinestatic

Definition at line 56 of file wchar.h.

57{
58 size_t i;
59 for (i = 0; i < n; i++)
60 {
61 if (s1[i] > s2[i]) return 1;
62 if (s1[i] < s2[i]) return -1;
63 }
64 return 0;
65}
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
struct S1 s1
PCWSTR s2
Definition: shell32_main.h:38

◆ wmemcpy()

static wchar_t *__cdecl wmemcpy ( wchar_t dst,
const wchar_t src,
size_t  n 
)
inlinestatic

Definition at line 67 of file wchar.h.

68{
69 return (wchar_t*)memcpy(dst, src, n * sizeof(wchar_t));
70}
GLenum src
Definition: glext.h:6340
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

Referenced by ATL::ChTraitsCRT< _CharType >::ConvertToBaseType(), and wmemcpy_s().

◆ wmemcpy_s()

_ACRTIMP errno_t __cdecl wmemcpy_s ( wchar_t destination,
size_t  size_in_elements,
const wchar_t source,
size_t  count 
)

Definition at line 18 of file wmemcpy_s.cpp.

24{
25 if (count == 0)
26 return 0;
27
28 _VALIDATE_RETURN_ERRCODE(destination != nullptr, EINVAL);
29
30 if (source == nullptr || size_in_elements < count)
31 {
32 // Zero the destination buffer:
33 wmemset(destination, 0, size_in_elements);
34
37
38 // Useless, but prefast is confused:
39 return EINVAL;
40 }
41
42#pragma warning(suppress:__WARNING_BANNED_API_USAGEL2) /* 28726 */
43 wmemcpy(destination, source, count);
44 return 0;
45}
size_t const size_in_elements
#define EINVAL
Definition: errno.h:44
#define ERANGE
Definition: errno.h:55
static wchar_t *__cdecl wmemset(wchar_t *s, wchar_t c, size_t n)
Definition: wchar.h:77
static wchar_t *__cdecl wmemcpy(wchar_t *dst, const wchar_t *src, size_t n)
Definition: wchar.h:67
#define _VALIDATE_RETURN_ERRCODE(expr, errorcode)

◆ wmemmove()

static wchar_t *__cdecl wmemmove ( wchar_t dst,
const wchar_t src,
size_t  n 
)
inlinestatic

Definition at line 72 of file wchar.h.

73{
74 return (wchar_t*)memmove(dst, src, n * sizeof(wchar_t));
75}
#define memmove(s1, s2, n)
Definition: mkisofs.h:881

Referenced by wmemmove_s().

◆ wmemset()

static wchar_t *__cdecl wmemset ( wchar_t s,
wchar_t  c,
size_t  n 
)
inlinestatic

Definition at line 77 of file wchar.h.

78{
79 size_t i;
80 for (i = 0; i < n; i++)
81 s[i] = c;
82 return s;
83}

Referenced by START_TEST(), test_Sid_Null(), and wmemcpy_s().