Previous Table of Contents Next


3.10.18. <wctype.h>

The header <wctype.h> declares several functions, analogous to those in <ctype.h> (see section 3.10.3) for classifying and converting wide characters, i.e., values of type wchar_t. <wctype.h> is a new header, introduced in NA1; it and its functions may not be present in all compilers. See section 3.10.17 for information on other wide character functions.

3.10.18.1. Wide Character Classification Functions

int iswupper(wint_t c)
int iswlower(wint_t c)
int iswalpha(wint_t c)
int iswdigit(wint_t c)
int iswalnum(wint_t c)
int iswxdigit(wint_t c)
int iswspace(wint_t c)
int iswpunct(wint_t c)
int iswprint(wint_t c)
int iswgraph(wint_t c)
int iswcntrl(wint_t c)

These functions all perform the same classification functions on wide characters as the correspondingly named functions of section 3.10.3.1 do on normal characters. The parameter type wint_t is related to wchar_t; see section 3.10.17 for a discussion.

3.10.18.2. Extended Wide Character Classification Functions

wctype_t wctype(const char *classname)
int iswctype(wint_t c, wctype_t classtok)

These functions permit new character classifications to be introduced without adding additional functions. wctype accepts a string classname indicating a character classification and returns a token that can be used for testing that classification. (The token type, wctype_t, is also defined in <wctype.h>.) iswctype accepts a wide character c and a token classtok previously returned by wctype, and returns nonzero if the character falls within the classification. wctype accepts the strings “upper”, “lower”, “alpha”, “digit”, “alnum”, “xdigit”, “space”, “punct”, “print”, “graph”, and “cntrl” (corresponding to the 11 predefined classifications), plus any implementation-defined classification strings an implementation chooses to provide.

3.10.18.3. Wide Character Conversion Functions

wint_t towupper(wint_t c)
wint_t towlower(wint_t c)

These functions perform the same conversion functions on wide characters as the correspondingly named functions of section 3.10.3.2 do on normal characters.

3.10.18.4. Extended Wide Character Conversion Functions

wctrans_t wctrans(const char *convname)
wint_t towctrans(wint_t c, wctrans_t convtok)

These functions permit new character conversions to be introduced without adding additional functions. wctrans accepts a string convname indicating a character conversion and returns a token that can be used for performing that conversion. (The token type, wctrans_t, is also defined in <wctype.h>.) towctrans accepts a wide character c and a token convtok previously returned by wctrans, and returns the appropriately converted wide character. wctrans accepts the strings “toupper” and “tolower” (corresponding to the two predefined classifications), plus any other conversion strings an implementation chooses to provide.

3.11. Acknowledgments

Thanks to Clive Feather for his invaluable summary of NA1. Thanks to Mark Brader, Jutta Degener, Dennis Ritchie, Melanie Summit, and Rob Young for reading and commenting on drafts of this manuscript.

3.12. Bibliography

American National Standards Institute. 1989. American national standard for information systems—Programming language—C, ANSI X3.159-1989.

Feather, C. D. W. A brief description of Normative Addendum 1, http://www.lysator.liu.se/c/na1.html.

Harbison, S. P., and G. L. Steele, Jr. 1995. C: A reference manual (4th ed.). Englewood Cliffs, NJ: Prentice -Hall.

Kernighan, B. W., and D. M. Ritchie. 1988. The C programming language (2nd ed.). Englewood Cliffs, NJ: Prentice -Hall.

Ritchie, D. M. 1993. The development of the C language. Second ACM HOPL Conference, Cambridge, MA. (See also this volume.)

Summit, S. 1995. C programming FAQs: Frequently asked questions. Reading, MA: Addison-Wesley.


Previous Table of Contents Next