64,648
社区成员
发帖
与我相关
我的任务
分享
//-------------------------------------------------------------------------------------
std::wstring STR_A2W (const char* p)
{
std::wstring ws ;
if (p)
{
#if (defined(_WIN32) || defined(__WIN32__))
int nCount = MultiByteToWideChar(CP_THREAD_ACP, 0, p, -1, NULL, 0) ;
if (nCount)
{
std::vector<wchar_t> wps (nCount+1) ;
MultiByteToWideChar(CP_THREAD_ACP, 0, p, -1, &wps[0], nCount) ;
ws = &wps[0] ;
}
#else
size_t nCount = strlen(p) ;
std::vector<wchar_t> wps (nCount+1) ;
setlocale (LC_CTYPE, "") ;
mbstowcs (&wps[0], p, nCount) ;
ws = &wps[0] ;
#endif
}
return ws ;
}