多位元組字串寬字串
阿新 • • 發佈:2018-12-31
LONG WideCharToMultiByteEx(const CStringW &StrFrom, CStringA &StrTo, UINT PageCode)
{
if (LONG nBytes = WideCharToMultiByte(PageCode, 0, StrFrom, StrFrom.GetLength(), NULL, 0, NULL, NULL))
{
return WideCharToMultiByte(PageCode, 0, StrFrom, StrFrom.GetLength(), StrTo.GetBufferSetLength(nBytes), nBytes, NULL , NULL);
}
return 0;
}
LONG MultiByteToWideCharEx(const CStringA &StrFrom, CStringW &StrTo, UINT PageCode)
{
if (LONG nCount = MultiByteToWideChar(PageCode, 0, StrFrom, StrFrom.GetLength(), NULL, 0))
{
return MultiByteToWideChar(PageCode, 0, StrFrom, StrFrom.GetLength(), StrTo.GetBufferSetLength(nCount), nCount);
}
return 0;
}
PageCode引數的作用
1.CHAR到WCHAR時表示CHAR的字元編碼是什麼
2.WCHAR到CHAR時表示轉換為什麼樣的字元編碼到CHAR中
我們一般所說的ANSI是GB2312, 中文簡體, PageCode是936