您的位置:首页 > 其它

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

2012-08-21 15:26 239 查看
// 将 宽字节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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: