Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

<wctype.h> — wide-character classification and mapping

The <wctype.h> header provides wide-character classification and mapping affected by LC_CTYPE.

Version: C23; repository compiler flag, production runtime not attested

Syntax

#include <wctype.h>

<wctype.h> declares, among others, iswalpha, towlower, the types wint_t, wctype_t, wctrans_t, and the macro WEOF. Predicates return zero or a nonzero value, not necessarily 1.

wctype and iswctype handle named classes; wctrans and towctrans handle named mappings. An unknown name yields a zero descriptor: check it before use.

A wint_t argument must be representable as wchar_t or equal WEOF; otherwise behavior is undefined. Results depend on LC_CTYPE. The example uses the initial "C" locale and normalizes results to 0 or 1.

Examples

#include <stdio.h>
#include <wctype.h>

int main(void)
{
    printf("alpha: %d\n", iswalpha(L'A') != 0);
    printf("lower: %d\n", towlower(L'A') == L'a');
    return 0;
}

Result

alpha: 1
lower: 1

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources