The Open Group Base Specifications Issue 7, 2018 edition
IEEE Std 1003.1-2017 (Revision of IEEE Std 1003.1-2008)
Copyright © 2001-2018 IEEE and The Open Group


iswctype, iswctype_l - test character for a specified class


#include <wctype.h>

int iswctype(wint_t
wc, wctype_t charclass);

[CX] [Option Start] int iswctype_l(wint_t wc, wctype_t charclass,
locale); [Option End]


For iswctype(): [CX] [Option Start]  The functionality described on this reference page is aligned with the ISO C standard. Any conflict between the requirements described here and the ISO C standard is unintentional. This volume of POSIX.1-2017 defers to the ISO C standard. [Option End]

The iswctype() [CX] [Option Start]  and iswctype_l() [Option End]  functions shall determine whether the wide-character code wc has the character class charclass, returning true or false. The iswctype() [CX] [Option Start]  and iswctype_l() [Option End] functions are defined on WEOF and wide-character codes corresponding to the valid character encodings in the current locale, or [CX] [Option Start]  in the locale represented by locale, [Option End] respectively. If the wc argument is not in the domain of the function, the result is undefined. If the value of charclass is invalid (that is, not obtained by a call to wctype() or charclass is invalidated by a subsequent call to setlocale() that has affected category LC_CTYPE) the result is unspecified.

[CX] [Option Start] The behavior is undefined if the locale argument to iswctype_l() is the special locale object LC_GLOBAL_LOCALE or is not a valid locale object handle. [Option End]


The iswctype() [CX] [Option Start]  and iswctype_l() [Option End]  functions shall return non-zero (true) if and only if wc has the property described by charclass. [CX] [Option Start]  If charclass is (wctype_t)0, these functions shall return 0. [Option End]


No errors are defined.

The following sections are informative.


Testing for a Valid Character
#include <wctype.h>
int yes_or_no;
wint_t wc;
wctype_t valid_class;
if ((valid_class=wctype("vowel")) == (wctype_t)0)
    /* Invalid character class. */


The twelve strings "alnum", "alpha", "blank", "cntrl", "digit", "graph", "lower", "print", "punct", "space", "upper", and "xdigit" are reserved for the standard character classes. In the table below, the functions in the left column are equivalent to the functions in the right column.

iswalnum(wc)            iswctype(wc, wctype("alnum"))
iswalnum_l(wc, locale)  iswctype_l(wc, wctype("alnum"), locale)
iswalpha(wc)            iswctype(wc, wctype("alpha"))
iswalpha_l(wc, locale)  iswctype_l(wc, wctype("alpha"), locale)
iswblank(wc)            iswctype(wc, wctype("blank"))
iswblank_l(wc, locale)  iswctype_l(wc, wctype("blank"), locale)
iswcntrl(wc)            iswctype(wc, wctype("cntrl"))
iswcntrl_l(wc, locale)  iswctype_l(wc, wctype("cntrl"), locale)
iswdigit(wc)            iswctype(wc, wctype("digit"))
iswdigit_l(wc, locale)  iswctype_l(wc, wctype("digit"), locale)
iswgraph(wc)            iswctype(wc, wctype("graph"))
iswgraph_l(wc, locale)  iswctype_l(wc, wctype("graph"), locale)
iswlower(wc)            iswctype(wc, wctype("lower"))
iswlower_l(wc, locale)  iswctype_l(wc, wctype("lower"), locale)
iswprint(wc)            iswctype(wc, wctype("print"))
iswprint_l(wc, locale)  iswctype_l(wc, wctype("print"), locale)
iswpunct(wc)            iswctype(wc, wctype("punct"))
iswpunct_l(wc, locale)  iswctype_l(wc, wctype("punct"), locale)
iswspace(wc)            iswctype(wc, wctype("space"))
iswspace_l(wc, locale)  iswctype_l(wc, wctype("space"), locale)
iswupper(wc)            iswctype(wc, wctype("upper"))
iswupper_l(wc, locale)  iswctype_l(wc, wctype("upper"), locale)
iswxdigit(wc)           iswctype(wc, wctype("xdigit"))
iswxdigit_l(wc, locale) iswctype_l(wc, wctype("xdigit"), locale)






iswalnum, iswalpha, iswcntrl, iswdigit, iswgraph, iswlower, iswprint, iswpunct, iswspace, iswupper, iswxdigit, setlocale, uselocale, wctype

XBD <locale.h>, <wctype.h>


First released as World-wide Portability Interfaces in Issue 4.

Issue 5

The following change has been made in this version for alignment with ISO/IEC 9899:1990/Amendment 1:1995 (E):

Issue 6

The behavior of charclass = (wctype_t)0 is now described.

An example is added.

A new function, iswblank(), is added to the list in the APPLICATION USAGE.

Issue 7

The iswctype_l() function is added from The Open Group Technical Standard, 2006, Extended API Set Part 4.

POSIX.1-2008, Technical Corrigendum 1, XSH/TC1-2008/0321 [283] and XSH/TC1-2008/0322 [283] are applied.

POSIX.1-2008, Technical Corrigendum 2, XSH/TC2-2008/0184 [799] and XSH/TC2-2008/0185 [799] are applied.

End of informative text.


return to top of page

UNIX ® is a registered Trademark of The Open Group.
POSIX ™ is a Trademark of The IEEE.
Copyright © 2001-2018 IEEE and The Open Group, All Rights Reserved
[ Main Index | XBD | XSH | XCU | XRAT ]