wcstombs_s、mbstowcs_s 函数原型参考MSDN。
根据MSDN上的例子修改:
1 char szDest[BUFFER_SIZE] = {0};
2 wchar_t* pwszSrc = L"你好";
3 size_t uiLen;
4
5 // 如果没有这一句话,中文显示不正确
6 _tsetlocale(LC_ALL,_T(""));
7
8 wcstombs_s(&uiLen, szDest, (size_t)BUFFER_SIZE, pwszSrc, (size_t)BUFFER_SIZE);
9
10 cout << " Characters converted: " << uiLen << endl
11 << " Multibyte character: " << szDest << endl;
12
13 wchar_t wszDest[BUFFER_SIZE] = {0};
14 char* pszSrc = "我也好";
15 mbstowcs_s(&uiLen, wszDest, (size_t)BUFFER_SIZE, pszSrc, (size_t)BUFFER_SIZE);
16
17 cout << " Characters converted: " << uiLen << endl
18 << " byte character: " << szDest << endl;
posted on 2010-03-05 20:24
郭小帅 阅读(593)
评论(0) 编辑 收藏 引用 所属分类:
API