wchar -->> char ... 기타 등등..

// char to LPCWSTR
void CharToWChar( const char* pstrSrc, wchar_t pwstrDest[] )
{
	int nLen = ( int )strlen( pstrSrc ) + 1;
	mbstowcs( pwstrDest, pstrSrc, nLen );
}

// LPCWSTR to char
void WCharToChar( const wchar_t* pwstrSrc, char pstrDest[] )
{
	int nLen = ( int )wcslen( pwstrSrc );
	wcstombs( pstrDest, pwstrSrc, nLen + 1 );
}

//////////////////////////////////////////////////////////////////////////
 
// char -> wchar_t

wchar_t* CharToWChar(char* pstrSrc)

{

    int nLen = (int)strlen(pstrSrc)+1;

    wchar_t* pwstr = (LPWSTR)malloc(sizeof(wchar_t)*nLen);

    mbstowcs(pwstr, pstrSrc, nLen);

    return pwstr;

}

 

// wchar -> char

char* WCharToChar(wchar_t* pwstrSrc)

{

    int nLen = (int)wcslen(pwstrSrc)+1;

    char* pstr = (char*)malloc(sizeof(char)*nLen);

    wcstombs(pstr, pwstrSrc, nLen);

    return pstr;

}




char sz[10] = "123가나다라마바사"; WCHAR szw[10] = L"123가나다라마바사"; USES_CONVERSION; WCHAR* w = A2W( sz ); // char -> wchar CHAR* c = W2A( szw ); // wchar -> char


'Module > WindowsMFC' 카테고리의 다른 글

atoi() _wtoi() 문자열안에서 "문자열"검색!  (0) 2008.10.07
memset memcpy memcpy_s [정리] C  (0) 2008.10.07
WCHAR 를 CHAR 로 바꾸기...  (0) 2008.10.07
recv() WCHAR 로 받을때  (0) 2008.10.07
MFC flash 연동하기 - 1  (0) 2008.09.18

댓글

Designed by JB FACTORY