문자열 변환 [아스키 유니코드] ASCII <-> UNICODE
< 문자열 변환 > ASCII <-> UNICODE
wstring ATOW(string sStr);
string WTOA(wstring wStr);
//▷ASCII ==> UNICODE 변환방법
wstring CDownClientDlg::ATOW(string sStr)
{
BSTR bStr;
int nLen = MultiByteToWideChar(CP_ACP, 0, sStr.c_str(), sStr.size(), NULL, NULL);
bStr = SysAllocStringLen(NULL, nLen);
MultiByteToWideChar(CP_ACP, 0, sStr.c_str(), sStr.size(), bStr, nLen);
wstring wStr = bStr;
SysFreeString(bStr);
return wStr;
}
//▷UNICODE ==> ASCII 변환방법
string CDownClientDlg::WTOA(wstring wStr)
{
int nLen = wStr.size()*2;
char* szStr = new char[nLen+1];
memset(szStr, 0, nLen+1);
WideCharToMultiByte(CP_ACP, 0, wStr.c_str(), -1, szStr, nLen, NULL, NULL);
string sStr = szStr;
if(szStr) delete szStr;
szStr = NULL;
return sStr;
}
//---------------------------------------------------
// string/wstring 사용하기.
//---------------------------------------------------
#include <string>
using namespace std;
//---------------------------------------------------/