Share via


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

另請參閱

資料轉換
地區設定
_mbclen, mblen, _mblen_l
mbstowcs, _mbstowcs_l
mbtowc, _mbtowc_l
wctomb, _wctomb_l
WideCharToMultiByte