// 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