宽字节wchar_t* 转换 单字节char*

// 将 宽字节wchar_t* 转换 单字节char*
inline std::string UnicodeToAnsi( const wchar_t* szStr )
{
int nLen = WideCharToMultiByte( CP_ACP, 0, szStr, -1, NULL, 0, NULL, NULL );
if (nLen == 0)
{
  return NULL;
}
//char* pResult = new char[nLen];
std::string res;
res.resize(nLen);
WideCharToMultiByte( CP_ACP, 0, szStr, -1, (char*)res.c_str(), nLen, NULL, NULL );
return res;

}


你可能感兴趣的:(宽字节wchar_t* 转换 单字节char*)