欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
CString、TCHAR*、char*轉換
char*、TCHAR*轉換CString 
CString str(****) 
下面詳細寫(xiě)一下其它轉換 
////////////////////////////// 
/* 
*********************************************************************** 
* 函數: TransCStringToTCHAR 
* 描述:將CString 轉換為 TCHAR* 
* 日期:
*********************************************************************** 
*/ 
TCHAR* CPublic::CString2TCHAR(CString &str) 
int iLen = str.GetLength(); 
TCHAR* szRs = new TCHAR[iLen]; 
lstrcpy(szRs, str.GetBuffer(iLen)); 
str.ReleaseBuffer(); 
return szRs; 
/* 
*********************************************************************** 
* 函數: TCHAR2Char 
* 描述:將TCHAR* 轉換為 char* 
* 日期:


*********************************************************************** 
*/ 
char* TCHAR2char(TCHAR* tchStr) 
int iLen = 2*wcslen(tchStr);//CString,TCHAR漢字算一個(gè)字符,因此不用普通計算長(cháng)度 
char* chRtn = new char[iLen+1] 
wcstombs(chRtn,tchStr,iLen+1);//轉換成功返回為非負值 
return chRtn; 
/*

*********************************************************************** 
* 函數: char2tchar
* 描述:將 char* 轉換為 TCHAR*
* 日期:


*********************************************************************** 
*/ 
TCHAR *char2tchar(char *str)
{
int iLen = strlen(str);
TCHAR *chRtn = new TCHAR[iLen+1];
mbstowcs(chRtn, str, iLen+1);
return chRtn;
}
/* 
*********************************************************************** 
* 函數: CString2char 
* 描述:將CString轉換為 char* 
* 日期:
*********************************************************************** 
*/ 
char* CPublic::CString2char(CString &str) 
int len = str.GetLength(); 
char* chRtn = (char*)malloc((len*2+1)*sizeof(char));//CString的長(cháng)度中漢字算一個(gè)長(cháng)度 
memset(chRtn, 0, 2*len+1); 
USES_CONVERSION; 
strcpy((LPSTR)chRtn,OLE2A(str.LockBuffer())); 
return chRtn; 
//參考 
/////////////////////// 
//Pocket PC上的UNICODE和ANSI字符串 
//By Vassili Philippov, September 26, 2001. 
//楊方思歧 譯 
//////////////////////// 
/* 
*********************************************************************** 
* 函 數 名:GetAnsiString 
* 描 述:將CString(unicode)轉換為char*(ANSI) 
* 參 數:CString &s 要轉換的CString 
* 返 回 值:返回轉換結果 
* 創(chuàng )建日期:
* 最后修改:
*********************************************************************** 
*/ 
char* GetAnsiString(const CString &s) 
int nSize = 2*s.GetLength(); 
char *pAnsiString = new char[nSize+1]; 
wcstombs(pAnsiString, s, nSize+1); 
return pAnsiString; 
//////////////////////////////////////////////////////////////////////////////////////////////

WideCharToMultiByte和MultiByteToWideChar函數的用法
支持Unicode編碼,需要多字節與寬字節之間的相互轉換
WideCharToMultiByte的代碼頁(yè)用來(lái)標記與新轉換的字符串相關(guān)的代碼頁(yè)。
MultiByteToWideChar的代碼頁(yè)用來(lái)標記與一個(gè)多字節字符串相關(guān)的代碼頁(yè)。
常用的代碼頁(yè)由CP_ACP和CP_UTF8兩個(gè)。
使用CP_ACP代碼頁(yè)就實(shí)現了ANSI與Unicode之間的轉換。
使用CP_UTF8代碼頁(yè)就實(shí)現了UTF-8與Unicode之間的轉換。
wstring AnsiToUnicode(( const string& str )
{
int len = 0;
len = str.length();
int unicodeLen = ::MultiByteToWideChar( CP_ACP, 0, str.c_str(),-1,NULL,0 ); 
wchar_t * pUnicode; 
pUnicode = new wchar_t[unicodeLen+1]; 
memset(pUnicode,0,(unicodeLen+1)*sizeof(wchar_t)); 
::MultiByteToWideChar( CP_ACP,0, str.c_str(),-1, (LPWSTR)pUnicode, unicodeLen ); 
wstring rt; 
rt = ( wchar_t* )pUnicode;
delete pUnicode; 
return rt; 
}
string UnicodeToAnsi( const wstring& str )
{
char* pElementText;
int iTextLen;
// wide char to multi char
iTextLen = WideCharToMultiByte( CP_ACP, 0, str.c_str(), -1, NULL, 0, NULL, NULL );
pElementText = new char[iTextLen + 1];
memset( ( void* )pElementText, 0, sizeof( char ) * ( iTextLen + 1 ) );
::WideCharToMultiByte( CP_ACP, 0, str.c_str(), -1, pElementText,iTextLen,NULL,NULL );
string strText;
strText = pElementText;
delete[] pElementText;
return strText;
}
wstring UTF8ToUnicode(( const string& str )
{
int len = 0;
len = str.length();
int unicodeLen = ::MultiByteToWideChar( CP_UTF8, 0, str.c_str(),-1,NULL,0 ); 
wchar_t * pUnicode; 
pUnicode = new wchar_t[unicodeLen+1]; 
memset(pUnicode,0,(unicodeLen+1)*sizeof(wchar_t)); 
::MultiByteToWideChar( CP_UTF8,0, str.c_str(),-1, (LPWSTR)pUnicode, unicodeLen ); 
wstring rt; 
rt = ( wchar_t* )pUnicode;
delete pUnicode; 
return rt; 
}
string UnicodeToUTF8( const wstring& str )
{
char* pElementText;
int iTextLen;
// wide char to multi char
iTextLen = WideCharToMultiByte( CP_UTF8, 0, str.c_str(), -1, NULL, 0, NULL, NULL );
pElementText = new char[iTextLen + 1];
memset( ( void* )pElementText, 0, sizeof( char ) * ( iTextLen + 1 ) );
::WideCharToMultiByte( CP_UTF8, 0, str.c_str(), -1, pElementText,iTextLen,NULL,NULL );
string strText;
strText = pElementText;
delete[] pElementText;
return strText;
}

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
[轉]CString、TCHAR*、char*轉換 - 我的地盤(pán)的日志 - 網(wǎng)易博客
編碼轉換的方法(UNICODE/ASCII/UTF
WideCharToMultiByte和MultiByteToWideChar函數的用法
Unicode,UTF8互轉
vc字符串轉換處理:(絕對精華,收集所有的例子)
Unicode字符集下CString與char *轉換
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久