char* UnicodeToUtf8(const wchar_t* unicode)
{
int len;
len = WideCharToMultiByte(CP_UTF8, 0, unicode, -1, NULL, 0, NULL, NULL);
char *szUtf8 = (char*)malloc(len + 1);
memset(szUtf8, 0, len + 1);
WideCharToMultiByte(CP_UTF8, 0, unicode, -1, szUtf8, len, NULL, NULL);
return szUtf8;
}
int main(int argc, char *argv[])
{
wchar_t* wCharUnicode = L"中国";
char* cCharUtf = UnicodeToUtf8(wCharUnicode);
return 0;
}
Unicode 转 UTF-8
未经允许不得转载:程序员中文网 » Unicode 转 UTF-8