STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
wchar.h
Go to the documentation of this file.
1 //
2 // wchar.h
3 //
4 // Copyright (c) Microsoft Corporation. All rights reserved.
5 //
6 // All of the types, macros, and function declarations for all wide-character
7 // related functionality. Most of the functionality is in the #included
8 // <corecrt_wxxxx.h> headers, which are also #included by other public headers.
9 //
10 #pragma once
11 #define _INC_WCHAR
12 
13 #include <corecrt.h>
14 #include <corecrt_memcpy_s.h>
15 #include <corecrt_wconio.h>
16 #include <corecrt_wctype.h>
17 #include <corecrt_wdirect.h>
18 #include <corecrt_wio.h>
19 #include <corecrt_wprocess.h>
20 #include <corecrt_wstdio.h>
21 #include <corecrt_wstdlib.h>
22 #include <corecrt_wstring.h>
23 #include <corecrt_wtime.h>
24 #include <sys/stat.h>
25 #include <sys/types.h>
26 #include <vcruntime_string.h>
27 
29 
30 
31 
32 #define WCHAR_MIN 0x0000
33 #define WCHAR_MAX 0xffff
34 
35 
36 
37 typedef wchar_t _Wint_t;
38 
39 
40 
41 #if _CRT_FUNCTIONS_REQUIRED
42 
44  _ACRTIMP wchar_t* __cdecl _wsetlocale(
45  _In_ int _Category,
46  _In_opt_z_ wchar_t const* _Locale
47  );
48 
51  _In_ int _Category,
52  _In_z_ wchar_t const* _Locale
53  );
54 
55 
56 
57  _ACRTIMP wint_t __cdecl btowc(
58  _In_ int _Ch
59  );
60 
61  _ACRTIMP size_t __cdecl mbrlen(
63  _In_ size_t _SizeInBytes,
65  );
66 
67  _ACRTIMP size_t __cdecl mbrtowc(
68  _Pre_maybenull_ _Post_z_ wchar_t* _DstCh,
69  _In_reads_bytes_opt_(_SizeInBytes) _Pre_opt_z_ char const* _SrcCh,
70  _In_ size_t _SizeInBytes,
72  );
73 
74  _Success_(return == 0)
75  _ACRTIMP errno_t __cdecl mbsrtowcs_s(
76  _Out_opt_ size_t* _Retval,
77  _Out_writes_opt_z_(_Size) wchar_t* _Dst,
78  _In_ size_t _Size,
79  _Deref_pre_opt_z_ char const** _PSrc,
80  _In_ size_t _N,
82  );
83 
85  _Success_(return == 0)
86  errno_t, mbsrtowcs_s,
87  _Out_opt_ size_t*, _Retval,
88  _Post_z_ wchar_t, _Dest,
90  _In_ size_t, _Count,
91  _Inout_ mbstate_t*, _State
92  )
93 
95  _Success_(return == 0) _ACRTIMP, mbsrtowcs,
96  _Out_writes_opt_z_(_Count), wchar_t, _Dest,
97  _Deref_pre_opt_z_ char const**, _PSrc,
98  _In_ size_t, _Count,
99  _Inout_ mbstate_t*, _State
100  )
101 
102  _Success_(return == 0)
103  _ACRTIMP errno_t __cdecl wcrtomb_s(
104  _Out_opt_ size_t* _Retval,
105  _Out_writes_opt_z_(_SizeInBytes) char* _Dst,
106  _In_ size_t _SizeInBytes,
107  _In_ wchar_t _Ch,
108  _Inout_opt_ mbstate_t* _State
109  );
110 
112  _Success_(return == 0)
113  errno_t, wcrtomb_s,
114  _Out_opt_ size_t*, _Retval,
115  _Out_writes_opt_z_(_Size) char, _Dest,
116  _In_ wchar_t, _Source,
117  _Inout_opt_ mbstate_t*, _State
118  )
119 
121  _ACRTIMP, wcrtomb,
122  _Pre_maybenull_ _Post_z_, char, _Dest,
123  _In_ wchar_t, _Source,
124  _Inout_opt_ mbstate_t*, _State
125  )
126 
127  _Success_(return == 0)
128  _ACRTIMP errno_t __cdecl wcsrtombs_s(
129  _Out_opt_ size_t* _Retval,
130  _Out_writes_bytes_to_opt_(_SizeInBytes, *_Retval) char* _Dst,
131  _In_ size_t _SizeInBytes,
132  _Inout_ _Deref_prepost_z_ wchar_t const** _Src,
133  _In_ size_t _Size,
134  _Inout_opt_ mbstate_t* _State
135  );
136 
138  _Success_(return == 0)
139  errno_t, wcsrtombs_s,
140  _Out_opt_ size_t*, _Retval,
141  _Out_writes_opt_z_(_Size) char, _Dest,
142  _Inout_ _Deref_prepost_z_ wchar_t const**, _PSrc,
143  _In_ size_t, _Count,
144  _Inout_opt_ mbstate_t*, _State
145  )
146 
148  _ACRTIMP, wcsrtombs,
149  _Pre_maybenull_ _Post_z_, char, _Dest,
150  _Inout_ _Deref_prepost_z_ wchar_t const**, _PSource,
151  _In_ size_t, _Count,
152  _Inout_opt_ mbstate_t*, _State
153  )
154 
155  _ACRTIMP int __cdecl wctob(
156  _In_ wint_t _WCh
157  );
158 
159  #if __STDC_WANT_SECURE_LIB__
160 
161  _Success_(return == 0)
162  errno_t __CRTDECL wmemcpy_s(
163  _Out_writes_to_opt_(_N1, _N) wchar_t* _S1,
164  _In_ rsize_t _N1,
165  _In_reads_opt_(_N) wchar_t const* _S2,
166  _In_ rsize_t _N
167  );
168 
169  _Success_(return == 0)
170  errno_t __CRTDECL wmemmove_s(
171  _Out_writes_to_opt_(_N1, _N) wchar_t* _S1,
172  _In_ rsize_t _N1,
173  _In_reads_opt_(_N) wchar_t const* _S2,
174  _In_ rsize_t _N
175  );
176 
177  #endif // __STDC_WANT_SECURE_LIB__
178 
179  __inline int __CRTDECL fwide(
180  _In_opt_ FILE* _F,
181  _In_ int _M
182  )
183  {
184  _CRT_UNUSED(_F);
185  return (_M);
186  }
187 
188  __inline int __CRTDECL mbsinit(
189  _In_opt_ mbstate_t const* _P
190  )
191  {
192  return _P == NULL || _P->_Wchar == 0;
193  }
194 
195  __inline wchar_t _CONST_RETURN* __CRTDECL wmemchr(
196  _In_reads_(_N) wchar_t const* _S,
197  _In_ wchar_t _C,
198  _In_ size_t _N
199  )
200  {
201  for (; 0 < _N; ++_S, --_N)
202  if (*_S == _C)
203  return (wchar_t _CONST_RETURN*)_S;
204 
205  return 0;
206  }
207 
208  __inline int __CRTDECL wmemcmp(
209  _In_reads_(_N) wchar_t const* _S1,
210  _In_reads_(_N) wchar_t const* _S2,
211  _In_ size_t _N
212  )
213  {
214  for (; 0 < _N; ++_S1, ++_S2, --_N)
215  if (*_S1 != *_S2)
216  return *_S1 < *_S2 ? -1 : 1;
217 
218  return 0;
219  }
220 
221  _Post_equal_to_(_S1)
222  _At_buffer_(_S1, _Iter_, _N, _Post_satisfies_(_S1[_Iter_] == _S2[_Iter_]))
223  __inline _CRT_INSECURE_DEPRECATE_MEMORY(wmemcpy_s)
224  wchar_t* __CRTDECL wmemcpy(
225  _Out_writes_all_(_N) wchar_t* _S1,
226  _In_reads_(_N) wchar_t const* _S2,
227  _In_ size_t _N
228  )
229  {
230  #pragma warning(push)
231  #pragma warning(disable : 4995 4996 6386)
232  return (wchar_t*)memcpy(_S1, _S2, _N*sizeof(wchar_t));
233  #pragma warning(pop)
234  }
235 
236  __inline _CRT_INSECURE_DEPRECATE_MEMORY(wmemmove_s)
237  wchar_t* __CRTDECL wmemmove(
238  _Out_writes_all_opt_(_N) wchar_t* _S1,
239  _In_reads_opt_(_N) wchar_t const* _S2,
240  _In_ size_t _N
241  )
242  {
243  #pragma warning(push)
244  #pragma warning(disable : 4996 6386)
245  return (wchar_t*)memmove(_S1, _S2, _N*sizeof(wchar_t));
246  #pragma warning(pop)
247  }
248 
250  _At_buffer_(_S, _Iter_, _N, _Post_satisfies_(_S[_Iter_] == _C))
251  __inline wchar_t* __CRTDECL wmemset(
252  _Out_writes_all_(_N) wchar_t* _S,
253  _In_ wchar_t _C,
254  _In_ size_t _N
255  )
256  {
257  wchar_t *_Su = _S;
258  for (; 0 < _N; ++_Su, --_N)
259  {
260  *_Su = _C;
261  }
262  return _S;
263  }
264 
265  #ifdef __cplusplus
266 
267  extern "C++" inline wchar_t* __CRTDECL wmemchr(
268  _In_reads_(_N) wchar_t* _S,
269  _In_ wchar_t _C,
270  _In_ size_t _N
271  )
272  {
273  wchar_t const* const _SC = _S;
274  return const_cast<wchar_t*>(wmemchr(_SC, _C, _N));
275  }
276 
277  #endif // __cplusplus
278 
279 #endif // _CRT_FUNCTIONS_REQUIRED
280 
281 
282 
return
Definition: corecrt_memcpy_s.h:60
#define _In_reads_bytes_opt_(size)
Definition: sal.h:319
_Pre_maybenull_ _In_ _Source
Definition: wchar.h:121
Definition: corecrt.h:489
_VCRTIMP void *__cdecl memmove(_Out_writes_bytes_all_opt_(_Size) void *_Dst, _In_reads_bytes_opt_(_Size) void const *_Src, _In_ size_t _Size)
#define _ACRTIMP
Definition: corecrt.h:27
#define _CRT_UNUSED(x)
Definition: corecrt.h:184
#define _Out_opt_
Definition: sal.h:343
_Pre_maybenull_ _Inout_ _Deref_prepost_z_ wchar_t const _In_ _Count
Definition: wchar.h:148
#define _Check_return_opt_
Definition: corecrt.h:96
_Iter_
Definition: wchar.h:222
_Post_equal_to_(_S1) _At_buffer_(_S1
_Pre_maybenull_ _Dest
Definition: wchar.h:121
__DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_2(_Success_(return==0) errno_t, wcrtomb_s, _Out_opt_ size_t *, _Retval, _Out_writes_opt_z_(_Size) char, _Dest, _In_ wchar_t, _Source, _Inout_opt_ mbstate_t *, _State) __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_SIZE(_ACRTIMP
unsigned short wint_t
Definition: corecrt.h:477
_Success_(return==0) _ACRTIMP errno_t __cdecl mbsrtowcs_s(_Out_opt_ size_t *_Retval
wchar_t _Wint_t
Definition: wchar.h:37
#define _Out_writes_all_(size)
Definition: sal.h:354
_In_ size_t _Deref_pre_opt_z_ char const _In_ size_t _N
Definition: wchar.h:78
int errno_t
Definition: corecrt.h:476
wcrtomb
Definition: wchar.h:121
size_t rsize_t
Definition: corecrt.h:527
__inline _CRT_INSECURE_DEPRECATE_MEMORY(wmemmove_s) wchar_t *__CRTDECL wmemmove(_Out_writes_all_opt_(_N) wchar_t *_S1
#define _CRT_BEGIN_C_HEADER
Definition: vcruntime.h:73
__inline int __CRTDECL wmemcmp(_In_reads_(_N) wchar_t const *_S1, _In_reads_(_N) wchar_t const *_S2, _In_ size_t _N)
Definition: wchar.h:208
_ACRTIMP size_t __cdecl mbrtowc(_Pre_maybenull_ _Post_z_ wchar_t *_DstCh, _In_reads_bytes_opt_(_SizeInBytes) _Pre_opt_z_ char const *_SrcCh, _In_ size_t _SizeInBytes, _Inout_ mbstate_t *_State)
_ACRTIMP wint_t __cdecl btowc(_In_ int _Ch)
#define _Deref_prepost_opt_valid_
Definition: sal.h:1459
_Pre_maybenull_ _In_ _Inout_opt_ mbstate_t _State _In_ size_t _SizeInBytes
Definition: wchar.h:131
#define _Deref_pre_opt_z_
Definition: sal.h:1027
#define __CRTDECL
Definition: vcruntime.h:156
#define _Pre_maybenull_
Definition: sal.h:678
#define _In_opt_z_
Definition: sal.h:311
__DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_3(_Success_(return==0) errno_t, mbsrtowcs_s, _Out_opt_ size_t *, _Retval, _Post_z_ wchar_t, _Dest, _Inout_ _Deref_prepost_opt_valid_ char const **, _PSource, _In_ size_t, _Count, _Inout_ mbstate_t *, _State) __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_3_SIZE(_Success_(return
_Post_satisfies_(_S1[_Iter_]==_S2[_Iter_])) __inline _CRT_INSECURE_DEPRECATE_MEMORY(wmemcpy_s) wchar_t *__CRTDECL wmemcpy(_Out_writes_all_(_N) wchar_t *_S1
#define _Pre_opt_z_
Definition: sal.h:1271
_Check_return_ _In_ wchar_t _Ch
Definition: vcruntime_string.h:89
#define _In_z_
Definition: sal.h:310
#define _In_
Definition: sal.h:305
_N wchar_t * _S1
Definition: wchar.h:163
_Pre_maybenull_ _Inout_ _Deref_prepost_z_ wchar_t const _In_ _Inout_opt_ mbstate_t _State _ACRTIMP int __cdecl wctob(_In_ wint_t _WCh)
#define _Inout_opt_
Definition: sal.h:376
#define _CONST_RETURN
Definition: corecrt.h:79
#define _In_opt_
Definition: sal.h:306
_Pre_maybenull_ _In_ _Inout_opt_ mbstate_t _State _In_ size_t _Inout_ _Deref_prepost_z_ wchar_t const ** _Src
Definition: wchar.h:131
_In_ size_t _Deref_pre_opt_z_ char const _In_ size_t _Inout_ mbstate_t * _State
Definition: wchar.h:78
#define _Out_writes_all_opt_(size)
Definition: sal.h:355
Definition: corecrt_wstdio.h:25
_In_ wchar_t _C
Definition: wchar.h:253
_N wchar_t _In_ rsize_t _N1
Definition: wchar.h:163
_Check_return_opt_ _ACRTIMP wchar_t *__cdecl _wsetlocale(_In_ int _Category, _In_opt_z_ wchar_t const *_Locale)
_N wchar_t _In_ rsize_t _In_reads_opt_(_N) wchar_t const *_S2
#define _Deref_prepost_z_
Definition: sal.h:1420
_Pre_maybenull_ _In_ _Inout_opt_ mbstate_t _State _Out_writes_bytes_to_opt_(_SizeInBytes,*_Retval) char *_Dst
__inline int __CRTDECL mbsinit(_In_opt_ mbstate_t const *_P)
Definition: wchar.h:188
__inline wchar_t _CONST_RETURN *__CRTDECL wmemchr(_In_reads_(_N) wchar_t const *_S, _In_ wchar_t _C, _In_ size_t _N)
Definition: wchar.h:195
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_SIZE(_DeclSpec, _FuncName, _SalAttributeDst, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2)
Definition: corecrt.h:736
_In_reads_(_N) wchar_t const *_S2
wcsrtombs
Definition: wchar.h:148
memcpy(_Destination, _Source, _SourceSize)
#define _CRT_END_C_HEADER
Definition: vcruntime.h:76
return _S
Definition: wchar.h:262
_ACRTIMP size_t __cdecl mbrlen(_In_reads_bytes_opt_(_SizeInBytes) _Pre_opt_z_ char const *_Ch, _In_ size_t _SizeInBytes, _Inout_ mbstate_t *_State)
#define _At_buffer_(target, iter, bound, annos)
Definition: sal.h:247
_Pre_maybenull_ _Inout_ _Deref_prepost_z_ wchar_t const _PSource
Definition: wchar.h:148
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_3_SIZE(_DeclSpec, _FuncName, _SalAttributeDst, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3)
Definition: corecrt.h:771
_In_ size_t _Size
Definition: wchar.h:78
_Pre_maybenull_ _Post_z_
Definition: wchar.h:121
#define _Inout_
Definition: sal.h:375
_Check_return_opt_ _In_opt_ _locale_t const _Locale
Definition: corecrt_wconio.h:289
__inline int __CRTDECL fwide(_In_opt_ FILE *_F, _In_ int _M)
Definition: wchar.h:179
Definition: corecrt.h:497
_Out_writes_opt_z_(_Size) wchar_t *_Dst
#define _Out_writes_to_opt_(size, count)
Definition: sal.h:353
_Check_return_opt_ _ACRTIMP _locale_t __cdecl _wcreate_locale(_In_ int _Category, _In_z_ wchar_t const *_Locale)
#define NULL
Definition: corecrt.h:158
_In_ size_t _Deref_pre_opt_z_ char const ** _PSrc
Definition: wchar.h:78