wchar_t*,wchar_t,wchat_t数组,char,char*,char数组,std::string,std::wstring,CString
来源:互联网 发布:卖家淘宝客如何推广 编辑:程序博客网 时间:2024/05/22 00:33
- #include <string>
- #define _AFXDLL
- #include <afx.h>
- using namespace std;
- inline wchar_t* AnsiToUnicode( const char* szStr )
- {
- int nLen = MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, szStr, -1, NULL, 0 );
- if (nLen == 0)
- {
- return NULL;
- }
- wchar_t* pResult = new wchar_t[nLen];
- MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, szStr, -1, pResult, nLen );
- return pResult;
- }
- inline char* UnicodeToAnsi( const wchar_t* szStr )
- {
- int nLen = WideCharToMultiByte( CP_ACP, 0, szStr, -1, NULL, 0, NULL, NULL );
- if (nLen == 0)
- {
- return NULL;
- }
- char* pResult = new char[nLen];
- WideCharToMultiByte( CP_ACP, 0, szStr, -1, pResult, nLen, NULL, NULL );
- return pResult;
- }
- inline void Ascii2WideString( const std::string& szStr, std::wstring& wszStr )
- {
- int nLength = MultiByteToWideChar( CP_ACP, 0, szStr.c_str(), -1, NULL, NULL );
- wszStr.resize(nLength);
- LPWSTR lpwszStr = new wchar_t[nLength];
- MultiByteToWideChar( CP_ACP, 0, szStr.c_str(), -1, lpwszStr, nLength );
- wszStr = lpwszStr;
- delete [] lpwszStr;
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- char* pChar = "我喜欢char";
- wchar_t* pWideChar = L"我讨厌wchar_t";
- wchar_t tagWideCharList[100] ;
- char ch = 'A';
- char tagChar[100] = {NULL};
- CString cStr;
- std::string str;
- setlocale(LC_ALL,"chs");
- pWideChar = AnsiToUnicode( pChar );
- printf( "%ls/n", pWideChar );
- wcscpy ( tagWideCharList, pWideChar );
- wprintf( L"%s/n", tagWideCharList );
- pWideChar = tagWideCharList;
- wprintf( L"%s/n", pWideChar );
- str.insert( str.begin(), ch );
- cout << str << endl;
- pWideChar = new wchar_t[str.length()];
- swprintf( pWideChar, L"%s", str.c_str());
- wprintf( L"%s/n", pWideChar );
- pChar = const_cast<char*>(str.c_str());
- cout << pChar << endl;
- str = std::string(pChar);
- cout << str << endl;
- str = "无聊啊无聊";
- strcpy( tagChar, str.c_str() );
- printf( "%s/n", tagChar );
- cStr = str.c_str();
- str = string(cStr.GetBuffer(cStr.GetLength()));
- cStr = pChar;
- pChar = cStr.GetBuffer( cStr.GetLength() );
- strncpy( tagChar, (LPCTSTR)CString, sizeof(tagChar));
- pWideChar = cStr.AllocSysString();
- printf( "%ls/n", pWideChar );
- }
- wchar_t*,wchar_t,wchat_t数组,char,char*,char数组,std::string,std::wstring,CString....转换
- wchar_t*,wchar_t,wchat_t数组,char,char*,char数组,std::string,std::wstring,CString 以及system("command")
- std::string,std::wstring,CString,char,char*,char数组,wchar_t*,wchar_t,wchat_t数组
- wchar_t*,wchar_t,wchat_t数组,char,char*,char数组,std::string,std::wstring,CString
- wchar_t*,wchar_t,wchat_t数组,char,char*,char数组,std::string,std::wstring,CString....转换
- wchar_t*,wchar_t,wchat_t数组,char,char*,char数组,std::string,std::wstring,CString....
- wchar_t*,wchar_t,wchat_t数组,char,char*,char数组,std::string,std::wstring,CString....
- wchar_t*,wchar_t,wchat_t数组,char,char*,char数组,std::string,std::wstring,CString转自由骑士大哥的)
- 【转】wchar_t*,wchar_t,wchat_t数组,char,char*,char数组,std::string,std::wstring,CString....相互之间的转化
- {wchar_t*, wchar_t, wchat_t数组},{char,char*,char数组},{std::string,std::wstring},CString之间的相互转换
- wchar_t*,wchar_t,wchat_t数组,char,char*,char数组,std::string,std::wstring,CStrin
- wchar_t,char,std::string,std::wstring,CString转换
- wchar_t,char,std::string,std::wstring,CString转换
- wchar_t char std::string std::wstring CString 转换
- [转]wchar_t char std::string std::wstring CString 转换
- [转]wchar_t char std::string std::wstring CString 转换
- [转载]wchar_t*,wchar_t,wchat_t数组,char,char*,char数组
- wchar_t*,wchar_t,wchat_t数组,char,char*,char数组
- 智能指针的用法
- 避免InvokeRequired(2)
- Oracle job说明
- decode
- CsrssWalker
- wchar_t*,wchar_t,wchat_t数组,char,char*,char数组,std::string,std::wstring,CString
- asterisk 中 开启cdr表通话记录
- 简单总结--JavaWeb开发中的附件上传 不要再混乱!
- 周二的阶段性成果汇报会
- SetForegroundWindow()
- 转师兄转的文章 什么是Windows能干而Linux干不了的
- 这周的任务
- 关于编程学习的七点思索
- 我的博客开通了