CString str; //里面是UTF-8编码
const char *pstr = LPCTSTR(str);
int iLength = MultiByteToWideChar(950,0,pstr,-1,NULL,0);
WCHAR *pstrG = new WCHAR[iLength + 2]; //UNICODE码
//转换UTF-8码到Unicode码,使用API函数MultiByteToWideChar
MultiByteToWideChar(950,0,pstr,-1,pstrG,iLength);
iLength = WideCharToMultiByte(936, 0, (PWSTR)pstrG, -1, NULL, 0, NULL, NULL);
//给pszGbt分配内存
char* psz=new char[iLength+1];
if( !psz )
return true;
//转换Unicode码到AscII码,使用API函数WideCharToMultiByte
WideCharToMultiByte(936, 0, (PWSTR)pstrG, -1, psz, iLength, NULL, NULL);
str = psz;
delete psz;
psz = NULL;
const char *pstr = LPCTSTR(str);
int iLength = MultiByteToWideChar(950,0,pstr,-1,NULL,0);
WCHAR *pstrG = new WCHAR[iLength + 2]; //UNICODE码
//转换UTF-8码到Unicode码,使用API函数MultiByteToWideChar
MultiByteToWideChar(950,0,pstr,-1,pstrG,iLength);
iLength = WideCharToMultiByte(936, 0, (PWSTR)pstrG, -1, NULL, 0, NULL, NULL);
//给pszGbt分配内存
char* psz=new char[iLength+1];
if( !psz )
return true;
//转换Unicode码到AscII码,使用API函数WideCharToMultiByte
WideCharToMultiByte(936, 0, (PWSTR)pstrG, -1, psz, iLength, NULL, NULL);
str = psz;
delete psz;
psz = NULL;
解决方案 »
- 请教些很杂碎的VC基础问题..
- 求《Visual C++ 6.0实效编程百例》,收到送分。感谢!
- MapObject 在VC环境下如何进行坐标转换,下面有部分代码,请高手指点?
- 谁有inside ole 2的源代码
- 请问有没有WinCE下给CListCtrl换肤的例子?
- 100分!!!如何将MSComm1.Output = "#01" & Chr$(13)语句转化成非控件,即API模式发送出去?VC的
- 请教,标题栏的字体怎么改变?
- I want to use the socket in an Extension Dll, that is used by the SNMP Service.But still I have a problem
- 请问如何实现网络CD播放器?(up有分)
- 一个简单的问题,一个重要的问题,欢迎大家来回答!!!
- 关于VC++结构体作为函数参数:BUG or 其它。
- 急请教CArray的赋值问题!!!!!!!!!!
就是UTF-8先解压成UNICODE,然后通过codepage取得相应的ascii