posts - 13,comments - 0,trackbacks - 0

           

          CString ConverToUTF8(CString szText)
          {
          	WCHAR *chBuf;
          	char * p;
          	int iLen;
          
              iLen = MultiByteToWideChar(CP_ACP, 0, szText,-1 , NULL, 0);
              chBuf = new WCHAR[iLen+1];
              ZeroMemory(chBuf, iLen * sizeof(WCHAR));
              iLen =MultiByteToWideChar(CP_ACP, 0, szText, -1, chBuf, iLen+1);
          
          	iLen = WideCharToMultiByte(CP_UTF8, 0, chBuf,-1 , NULL, 0,NULL,NULL);
          	p = new CHAR[iLen+1];
              ZeroMemory(p, iLen * sizeof(CHAR));
              iLen =WideCharToMultiByte(CP_UTF8, 0, chBuf, -1,  p, iLen+1,NULL,NULL);
          
          	delete []chBuf;
          	CString re(p);
          
          	return re;
          }
          
          CString UTF8ToUnicode(CString szText)
          {
          	int  len = 0;
          	len = szText.GetLength();
          	int  unicodeLen = ::MultiByteToWideChar( CP_UTF8,0,szText.GetBuffer(len),-1,NULL,0 ); 
          	
          	wchar_t *  pUnicode; 
          	pUnicode = new  wchar_t[unicodeLen+1]; 
          	
          	memset(pUnicode,0,(unicodeLen+1)*sizeof(wchar_t)); 
          	::MultiByteToWideChar( CP_UTF8,0,szText.GetBuffer(len),-1,(LPWSTR)pUnicode,unicodeLen ); 
          	
          	CString  rt = pUnicode; 
          	delete  pUnicode;
          	
          	return  rt; 	
          }   
            
          posted on 2011-02-21 14:48 CrackRen 閱讀(234) 評論(0)  編輯  收藏 所屬分類: VC實用算法

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導航:
           
          主站蜘蛛池模板: 报价| 岚皋县| 武冈市| 迭部县| 安丘市| 那坡县| 德清县| 新绛县| 尼玛县| 霸州市| 革吉县| 石城县| 蓬溪县| 江都市| 拉萨市| 巴楚县| 河北区| 绥滨县| 无锡市| 新泰市| 鄂州市| 湖南省| 玛纳斯县| 图片| 思茅市| 田阳县| 卢氏县| 仙游县| 交城县| 平邑县| 黄浦区| 赤峰市| 新晃| 县级市| 毕节市| 肇源县| 望谟县| 汪清县| 吉木乃县| 新建县| 德昌县|