ReactOS 0.4.16-dev-974-g5022a45
iswctype.cpp
Go to the documentation of this file.
1//
2// iswctype.cpp
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//
6// Support functionality for the wide character classification functions and
7// macros.
8//
9#include <corecrt_internal.h>
10#include <ctype.h>
11#include <locale.h>
12
13
14
15// Ensure that the masks used by GetCharType() match the CRT masks, so that we
16// can simply reinterpret the masks.
17#if _UPPER != C1_UPPER || \
18 _LOWER != C1_LOWER || \
19 _DIGIT != C1_DIGIT || \
20 _SPACE != C1_SPACE || \
21 _PUNCT != C1_PUNCT || \
22 _CONTROL != C1_CNTRL
23 #error Character type masks do not agree in ctype and winnls
24#endif
25
26
27
28// The iswctype functions are called by the wide character classification
29// functions and macros (e.g. iswalpha) when their argument is a wide
30// character greater than 255. It is also a standard function and can be
31// called by the user, even for characters less than 256. The function
32// returns nonzero if the argument c satisfies the character class property
33// encoded by the mask. Returns zero otherwise, or for WEOF. These functions
34// are neither locale nor codepage dependent.
35extern "C" int __cdecl _iswctype_l(wint_t const c, wctype_t const mask, _locale_t)
36{
37 return iswctype(c, mask);
38}
39
40extern "C" int __cdecl iswctype(wint_t const c, wctype_t const mask)
41{
42 if (c == WEOF)
43 return 0;
44
45 if (c < 256)
46 return static_cast<int>(_pwctype[c] & mask);
47
48 wchar_t const wide_character = c;
49
50 wint_t char_type = 0;
51 if (__acrt_GetStringTypeW(CT_CTYPE1, &wide_character, 1, &char_type) == 0)
52 return 0;
53
54 return static_cast<int>(char_type & mask);
55}
int wint_t
Definition: _apple.h:38
#define __cdecl
Definition: accygwin.h:79
const GLubyte * c
Definition: glext.h:8905
GLenum GLint GLuint mask
Definition: glext.h:6028
#define _pwctype
Definition: wctype.h:67
int __cdecl iswctype(wint_t const c, wctype_t const mask)
Definition: iswctype.cpp:40
int __cdecl _iswctype_l(wint_t const c, wctype_t const mask, _locale_t)
Definition: iswctype.cpp:35
#define c
Definition: ke_i.h:80
#define WEOF
Definition: conio.h:185
unsigned short wctype_t
Definition: corecrt.h:617
#define CT_CTYPE1
Definition: winnls.h:239