In 1995, a number of wide-character functions were added to the C89 standard, and were later incorporated into C99 and C++. The wide-character functions operate on characters of type wchar_t, which are 16 bits. For the most part, these functions parallel their char equivalents. For example, the function iswspace( ) is the wide-character version of isspace( ). In general, the wide-character functions use the same names as their char equivalents, except that a “w” is added.
For C, the wide-character functions use the headers <wchar.h> and <wctype.h>. For C++, the headers are <cwchar> and <cwctype>. This chapter will use the C header names, but references to <wchar.h> and <wctype.h> also apply to <cwchar> and <cwctype>, respectively.
The header <wctype.h> defines the types wint_t, wctrans_t, and wctype_t. Many of the wide-character functions receive a wide character as a parameter. The type of this parameter is wint_t. It is capable of holding a wide character. The use of the wint_t type in the wide-character functions parallels the use of int in the char-based functions. The types wctrans_t and wctype_t are the types of objects used to represent a character mapping (i.e., character translation) and the classification of a character, respectively. Also defined is the wide-character EOF mark, which is defined as WEOF.
In addition to defining win_t, the header <wchar.h> defines the types wchar_t, size_t, and mbstate_t. The wchar_t type creates a wide-character object, and size_t is the type of value returned by sizeof. The mbstate_t type describes an object that holds the state of a multibyte to wide-character conversion. The <wchar.h> header also defines the macros NULL, WEOF, WCHAR_MAX, and WCHAR_MIN. The last two define the maximum and minimum value that can be held in an object of type wchar_t.
Since most of the wide-character functions simply parallel their char equivalents, only a brief description of these functions is provided.