A character can be represented by single-byte or multibyte values depending on the codeset. To make it easier to handle both single- byte and multibyte characters in the same way, the DEC C RTL defines a wide-character data type, wchar_ t. This data type can store characters that are represented by 1-, 2-, 3-, or 4-byte values.
The functions provided to support wide characters are:
The LC_CTYPE category in a locale classifies the characters in the locale's codeset into different types (alphabetic, numeric, lowercase, uppercase, and so on). There are two sets of functions, one for wide characters and one for single-byte characters, that test whether a character is of a specific type. The is* functions test single-byte characters, and the isw* functions test wide characters.
For example, the iswalnum function tests if a wide character is classed as either alphabetic or numeric. It returns a nonzero value if the character is one of these types. For more information about the classification functions see Chapter 3 and the Reference Section.
The LC_CTYPE category defines mapping between pairs of characters of the locale. The most common character mapping is between uppercase and lowercase characters. However, a locale can support other than just case mappings.
Two functions are provided to map one character to another according to the information in the LC_CTYPE category of the locale:
Two functions are provided for character case mapping:
For more information about these functions, see the Reference Section.
The set of input and output functions manages wide characters and wide-character strings.
The functions for reading wide characters and wide-character strings are fgetwc, fgetws, getwc, and getwchar.
There is also an ungetwc function that pushes a wide character back into the input stream.
The functions for writing wide characters and wide-character strings are fputwc, fputws, putwc, and putwchar.
All the scan functions allow for a culture-specific radix character, as defined in the LC_NUMERIC category of the current locale.
The %lc, %C, %ls, and %S conversion specifiers enable the scan functions fwscanf, wscanf, swscanf, fscanf, scanf, and sscanf to read in wide characters.
All the print functions can format numeric values according to the data in the LC_NUMERIC category of the current locale.
The %lc, %C and %ls, %S conversion specifiers used with print functions convert wide characters to multibyte characters and print the resulting characters.
See Chapter 2 for details of all input and output functions.
Wide characters are used internally by an application to manage single-byte or multibyte characters. However, text files are generally stored in multibyte character format. To process these files, the multibyte characters need converting to wide-character format. This can be achieved using the following functions:
Similarly, the following functions convert wide characters into their multibyte equivalent:
Associated with these conversion functions, the mblen and mbrlen functions are used to determine the size of a multibyte character.
The DEC C RTL contains a set of functions (the wcs* and wmem* functions) that manipulate wide-character strings. For example, the wcscat function appends a wide-character string to the end of another string in the same way that the strcat function works on character strings of type char.
See Chapter 3 for details of the string manipulation functions.