现在的位置: 首页 > 综合 > 正文

将UTF8转成ANSISTRING

2012年09月03日 ⁄ 综合 ⁄ 共 594字 ⁄ 字号 评论关闭
 

  1. char * UTF8TOANSI(char *strUTF8)
  2. {
  3.     WCHAR*     strA;       
  4.     int     i=     MultiByteToWideChar     (     CP_UTF8     ,     0     ,(char*)     strUTF8     ,-1     ,NULL,0);       
  5.     strA     =     new     WCHAR[i];       
  6.     MultiByteToWideChar     (     CP_UTF8     ,     0     ,(     char     *     )     strUTF8,     -1,     strA     ,     i);       
  7.     i=     WideCharToMultiByte(CP_ACP,0,strA,-1,NULL,0,NULL,NULL);       
  8.     char *strAnsi=new     char[i];       
  9.     WideCharToMultiByte     (CP_ACP,0,strA,-1,strAnsi,i,NULL,NULL);       
  10.     delete     []strA;  
  11.     return strAnsi;
  12.     
  13. }

抱歉!评论已关闭.