2010년 4월 3일 토요일

C++ - MFC ASCII문자를 UNICODE(유니코드) 문자로 변환

웹페이지의 소스코드가 ASCII 문자일경우 UNICODE 문자로 변환이 필요해서
구글링해서 찾아서 함수로 꾸며봄..

BSTR unicodeConvert(CString sUnicode)
{
BSTR sResult;
int iLen = MultiByteToWideChar(CP_ACP, 0, (LPSTR)(LPCTSTR)sUnicode, sUnicode.GetLength()*2, NULL, NULL);
sResult = SysAllocStringLen(NULL, iLen);
MultiByteToWideChar(CP_ACP, 0, (LPSTR)(LPCTSTR)sUnicode, sUnicode.GetLength()*2, sResult, iLen);
return sResult;
}

BSTR bstr = unicodeConvert(strUnicode);

0 개의 댓글:

댓글 쓰기