Edit

Share via


wctob

Determines if a wide character corresponds to a multibyte character and returns its multibyte character representation.

Syntax

int wctob(
   wint_t wchar
);

Parameters

wchar
Value to translate.

Return value

If wctob successfully converts a wide character, it returns its multibyte character representation only if the multibyte character is a single byte long. If wctob encounters a wide character it can't convert to a multibyte character, or if the multibyte character isn't a single byte long, it returns -1.

Remarks

The wctob function converts a wide character contained in wchar to the corresponding multibyte character passed by the int return value, if the multibyte character is a single byte long.

If wctob was unsuccessful and no corresponding multibyte character was found, the function sets errno to EILSEQ and returns -1.

By default, this function's global state is scoped to the application. To change this behavior, see Global state in the CRT.

Requirements

Routine Required header
wctob <wchar.h>

For more compatibility information, see Compatibility.

Example

This program illustrates the behavior of the wctob function.

// crt_wctob.c
#include <stdio.h>
#include <wchar.h>

int main( void )
{
    int     bChar = 0;
    wint_t  wChar = 0;

    // Set the corresponding wide character to exactly one byte.
    wChar = (wint_t)'A';

    bChar = wctob( wChar );
    if (bChar == WEOF)
    {
        printf( "No corresponding multibyte character was found.\n");
    }
    else
    {
        printf( "Determined the corresponding multibyte character to"
                " be \"%c\".\n", bChar);
    }
}
Determined the corresponding multibyte character to be "A".

See also

Data conversion
Locale
_mbclen, mblen, _mblen_l
mbstowcs, _mbstowcs_l
mbtowc, _mbtowc_l
wctomb, _wctomb_l
WideCharToMultiByte