wctob

确定宽字符对应多字节字符,并返回该多字节字符的表示形式。

语法

int wctob(
   wint_t wchar
);

参数

wchar
要转换的值。

返回值

如果 wctob 成功转换宽字符,仅在多字节字符为单字节长度时返回该字符的表示形式。 如果 wctob 遇到无法转换为多字节字符的宽字符,或者多字节字符为单字节长度,则返回 –1。

备注

如果多字节字符为单字节长度,wctob 函数会将 wchar 中的宽字符转换为 int 返回值传递的相应多字节字符。

如果 wctob 失败且未找到相应的多字节字符,该函数会将 errno 设置为 EILSEQ 并返回 -1。

默认情况下,此函数的全局状态范围限定为应用程序。 若要更改此行为,请参阅 CRT 中的全局状态

要求

例程 必需的标头
wctob <wchar.h>

有关兼容性的详细信息,请参阅 兼容性

示例

本程序演示 wctob 函数的行为。

// 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".

另请参阅

数据转换
区域设置
_mbclenmblen_mblen_l
mbstowcs_mbstowcs_l
mbtowc_mbtowc_l
wctomb_wctomb_l
WideCharToMultiByte