Chinaunix首页 | 论坛 | 博客
  • 博客访问: 81536
  • 博文数量: 22
  • 博客积分: 1040
  • 博客等级: 少尉
  • 技术积分: 291
  • 用 户 组: 普通用户
  • 注册时间: 2008-05-15 11:20
文章分类

全部博文(22)

文章存档

2009年(1)

2008年(21)

我的朋友

分类:

2008-05-29 09:50:14

CString strMess = xml.GetData();
wchar_t*   szUnicodeString; 
szUnicodeString=strMess.AllocSysString();
UINT nCodePage = 936; //GB2312
int nLength=WideCharToMultiByte(nCodePage,0,szUnicodeString,-1,NULL,0,NULL,NULL);
   char* pBuffer=new char[nLength+1];
   WideCharToMultiByte(nCodePage,0,szUnicodeString,-1,pBuffer,nLength,NULL,NULL);
   pBuffer[nLength]=0;
 
函数:
char* UnicodeToGB2312(const wchar_t* szUnicodeString)
  {  
 /*char   *buffer   ;  
 buffer   =   new   char[sizeof(WCHAR)];  
 WideCharToMultiByte(CP_ACP,NULL,&uData,1,buffer,sizeof(WCHAR),NULL,NULL);  
 return   buffer;   */
 UINT nCodePage = 936; //GB2312
 int nLength=WideCharToMultiByte(nCodePage,0,szUnicodeString,-1,NULL,0,NULL,NULL);
 char* pBuffer=new char[nLength+1];
 WideCharToMultiByte(nCodePage,0,szUnicodeString,-1,pBuffer,nLength,NULL,NULL);
 pBuffer[nLength]=0;
 return pBuffer;
  }
 
阅读(574) | 评论(0) | 转发(0) |
0

上一篇:MessageBox的详解

下一篇:msxml 读xml

给主人留下些什么吧!~~