유니코드->아스키, 아스키->유니코드, 변환 Windows Api / 개발자료

2010/10/25 16:31

복사 http://blog.naver.com/ultimidou/130096142011

int Unicode2ASCII(WCHAR *uni, char *ascii)
{
int nLen = WideCharToMultiByte(CP_ACP, 0, uni, -1, NULL, 0, NULL, NULL);
WideCharToMultiByte(CP_ACP, 0, uni, -1, ascii, nLen, 0, 0);
return nLen;
}


int ASCII2Unicode(char *ascii, WCHAR *uni)
{
LPTSTR lpStr = ascii;
int nLen = MultiByteToWideChar(CP_ACP, 0,lpStr, -1, NULL, NULL);
MultiByteToWideChar(CP_ACP, 0, lpStr, -1, uni, nLen);
return nLen;
}


USES_CONVERSION; 를 사용한 후, 'W2A(x)'나 'A2W(x)' 매크로를 이용하여 문자열을 변환하는 방법도 있는데 깨지는 경우가 있다는군요...

출처: http://blog.naver.com/ultimidou/130097029985

'MFC' 카테고리의 다른 글

socket 함수 정의  (0) 2011.08.30
CBitmapButton 사용하는 방법  (0) 2011.08.30
각종 컨트롤의 배경색 변경하기  (0) 2011.08.30
스트링 형변환  (0) 2011.08.30
각종 윈도우 영역 크기 얻기  (0) 2011.08.26
Posted by pkss
,