The <cwctype>
header is a wrapper for the C standard <wctype.h>
header, which declares types and functions for classifying and converting wide characters.
Most of the functions in this header are wide equivalents of functions found in <cctype>
. For example, iswalnum
determines whether a wide character is alphanumeric, just as isalnum
determines whether a narrow (byte) character is alphanumeric. The behavior of the wide functions is similar to their narrow equivalents. In particular, for any narrow character c
, its wide character equivalent wc
, and classification functions isxyz
and iswxyx
, if isxyz(c)
is true then iswxyz(wc)
is true. The reverse is not necessarily true.
Determines whether a wide character is alphanumeric
int iswalnum(wint_t wc)
The iswalnum
function returns true if iswalpha(wc)
or iswdigit(wc)
is true.
iswalpha function, iswdigit function, isalnum in <cctype>
Determines whether a wide character is alphabetic
int iswalpha(wint_t wc)
The iswalpha
function returns true if wc
is an alphabetic character, that is, a wide character for which iswcntrl
, iswdigit
, iswpunct
, and iswspace
return false.
iswcntrl function, iswdigit function, iswpunct function, iswspace function, isalpha in <cctype>
Determines whether a wide character is a control character
int iswcntrl(wint_t wc)
The iswcntrl
function returns true if wc
is a wide control character, that is, a wide character for which iswalnum
, iswpunct
, and iswspace
return false.
iscntrl in <cctype>
Tests the type of a wide character
int iswctype(wint_t wc, wctype_t desc)
The iswctype
function determines whether the wide character wc
has the property desc
. The setting of the LC_CTYPE
category must be the same for the call to iswctype
and the call to wctype
that returned desc
.
For example, the iswalnum
function is equivalent to the following:
int iswalnum(wint_t wc) { return std::iswctype(wc, std::wctype("alnum")); }
wctype function, wctype_t type
Determines whether a wide character is a digit
int iswdigit(wint_t wc)
The iswdigit
function returns true if wc
is a decimal digit character, that is, '0'
through '9'
, regardless of locale.
iswxdigit function, isdigit in <cctype>
Determines whether a wide character is graphic
int iswgraph(wint_t wc)
The iswgraph
function returns true if iswprint(wc)
is true and iswspace(wc)
is false. Note that iswgraph
is slightly different from isgraph
for white space characters other than ' '
.
iswprint function, iswspace function
Determines whether a wide character is lowercase
int iswlower(wint_t wc)
The iswlower
function returns true if wc
is a lowercase character.
iswalpha function, iswupper function, towlower function, islower in <cctype>
Determines whether a wide character is printable
int iswprint(wint_t wc)
The iswprint
function returns true if wc
is a printing wide character.
iswgraph function, isprint in <cctype>
Determines whether a wide character is punctuation
int iswpunct(wint_t wc)
The iswpunct
function returns true if iswalnum(wc)
, iswcntrl(wc)
, and iswspace(wc)
are false.
iswalnum function, iswcntrl function, iswspace function, ispunct in <cctype>
Determines whether a wide character is white space
int iswspace(wint_t wc)
The iswspace
function returns true if wc
is a white space character.
iswgraph function, iswprint function, isspace in <cctype>
Determines whether a wide character is uppercase
int iswupper(wint_t wc)
The iswupper
function returns true if wc
is an uppercase character.
iswalpha function, iswlower function, towupper function, isupper in <cctype>
Determines whether a wide character is a hexadecimal digit
int iswxdigit(wint_t wc)
The iswxdigit
function returns true if wc
is a hexadecimal digit character, that is, '0'
through '9'
, 'a'
through 'f'
, or 'A'
though 'F'
, regardless of locale.
iswdigit function, isxdigit in <cctype>
Transform a wide character's case
wint_t towctrans(wint_t wc, wctrans_t desc)
The towctrans
function translates the wide character wc
according to the description desc
, which was returned from the wctrans
function. For example, the towlower
function can be implemented as follows:
wint_t towlower(wint_t wc) { return std::towctrans(wc, std::wctrans("tolower")); }
wctrans function, wctrans_t type
Convert a wide character to lowercase
wint_t towlower(wint_t wc)
The towlower
function maps the wide character wc
to lowercase. If iswupper(wc)
is false, or wc
has no lowercase mapping, wc
is returned unchanged.
towctrans function, towupper function, tolower in <cctype>
Convert a wide character to uppercase
wint_t towupper(wint_t wc)
The towupper
function maps the wide character wc
to uppercase. If iswlower(wc)
is false, or wc
has no uppercase mapping, wc
is returned unchanged.
towctrans function, towlower function, toupper in <cctype>
Construct a wctrans_t object
wctrans_t wctrans(const char* property)
The wctrans
function constructs a wctrans_t
object according to the given property. Table 13-7 lists the properties defined in the standard.
Property | Description |
---|---|
tolower |
Map from uppercase to lowercase |
toupper |
Map from lowercase to uppercase |
towctrans function, wctrans_t type
Represent a wide character translation
typedef ... wctrans_t
The wctrans_t
type is a scalar type, used to represent character mappings for the towctrans
function.
towctrans function, wctrans function, <clocale>
Construct a wctype_t object
wctype_t wctype(const char* property)
The wctype
function constructs a wctype_t
object that describes wide characters that have the given property. Table 13-8 lists the properties that are supported by this standard.
Property | Description |
---|---|
alnum |
Alphanumeric |
alpha |
Alphabetic |
cntrl |
Control |
digit |
Digit |
graph |
Non-space printable |
lower |
Lowercase |
print |
Printable or white space |
punct |
Punctuation |
space |
White space |
upper |
Uppercase |
xdigit |
Hexadecimal digit |
iswctype function, wctype_t type, <clocale>
Represent a character classification
typedef ... wctype_t
The wctype_t
type is a scalar type, used to represent character classifications for the iswctype
function.
iswctype function, wctype function, <clocale>
End of file or error
const wint_t WEOF
The WEOF
macro in a value that does not correspond to any valid wide character value. Unlike EOF
, WEOF
is not guaranteed to be negative.
WEOF in <cwchar>, EOF in <cstdio>
Integer representation of a wide character
typedef ... wint_t
The wint_t
type is an integral type that represents wide characters. It can hold the value for any character in the extended character set, plus the value WEOF
.
wint_t in <cwchar>