64,639
社区成员
发帖
与我相关
我的任务
分享
void UnicodeToAnsi( PCWSTR p, string & sz )
{
int nLen = WideCharToMultiByte( CP_ACP, 0, (wchar_t *)p, -1, NULL, 0, NULL, NULL );
if ( nLen <= 0 )
{
return ;
}
char* pResult = new char[nLen];
nLen = WideCharToMultiByte( CP_ACP, 0, (wchar_t *)p, -1, pResult, nLen, NULL, NULL );
sz = pResult;
delete [] pResult;
return ;
}
void AnsiToUnicode( PCSTR p, wstring & sz )
{
int nLen = MultiByteToWideChar( CP_ACP, 0, p, -1, NULL, 0 );
if ( nLen <= 0 )
{
return ;
}
wchar_t* pResult = new wchar_t[nLen];
nLen = MultiByteToWideChar( CP_ACP, 0, p, -1, pResult, nLen );
sz = pResult;
delete [] pResult;
return ;
}
delete []tempStr;