C 標(biāo)準(zhǔn)庫 - <stdlib.h>
C 庫函數(shù) int mbtowc(whcar_t *pwc, const char *str, size_t n) 把一個多字節(jié)序列轉(zhuǎn)換為一個寬字符。
下面是 mbtowc() 函數(shù)的聲明。
int mbtowc(whcar_t *pwc, const char *str, size_t n)
下面的示例演示了 mbtowc() 函數(shù)的用法。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char *str = "這里是 (cainiaoplus.com)";
wchar_t mb[100];
int len;
len = mblen(NULL, MB_CUR_MAX);
mbtowc(mb, str, len*strlen(str) );
wprintf(L"%ls \n", mb );
return(0);
}
讓我們編譯并運行上面的程序,這將產(chǎn)生以下結(jié)果,因為它要以多字節(jié)形式輸出結(jié)果,這是一種二進制輸出。
???