Name
wctob
Synopsis
Obtains the single-byte equivalent of a wide character, if any
#include <stdio.h> #include <wchar.h> intwctob( wint_twc);
The wctob() function
returns the single-byte member of the extended character set, if
there is one, that corresponds to its wide character argument,
wc.
To be more exact, wctob()
determines whether there is a character in the extended character
set which corresponds to the wide character
wc, and whose multibyte character
representation is expressed in a single byte in the initial shift
state of the locale’s multibyte encoding. If this is the case, then
wctob() returns that character,
converted from unsigned char to
int. If not, wctob() returns EOF.
Example
FILE *fp_inwide;
wchar_t wc;
int bc;
/* ... open the files ... */
fwide( fp_inwide, 1 );
while (( wc = fgetwc( fp_inwide )) != WEOF )
if (( bc =wctob( wc )) != EOF )
fputc( c, stdout );
else // If no byte-character equivalent,
fputc( '?', stdout ); // print a question mark instead.See Also
wctomb(), wcrtomb(), wcstombs(), and
wcsrtombs(); btowc(), mbtowc(), mbrtowc(), mbstowcs(), and
mbsrtowcs()
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access