Format
#include <stdio.h> #include <wchar.h> int wctob(wint_t wc);
Language Level: ANSI
Threadsafe: Yes.
Description
The wctob() function determines whether wc corresponds to a member of the extended character set, whose multibyte character has a length of 1 byte when in the initial shift state. The behavior of the wctob() function is affected by the LC_CTYPE category of the current locale.
Return Value
If c corresponds to a multibyte character with a length of 1 byte, the wctob() function returns the single-byte representation. Otherwise, it returns EOF.
If a conversion error occurs, errno may be set to ECONVERT.
Example that uses wctob()
This example uses the wctob() function to test if the wide character A is a valid single-byte character.
#include <stdio.h> #include <wchar.h> int main(void) { wint_t wc = L'A'; if (wctob(wc) == wc) printf("%lc is a valid single byte character\n", wc); else printf("%lc is not a valid single byte character\n", wc); return 0; /************************************************************ The output should be similar to: A is a valid single byte character ************************************************************/ }
Related Information
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.