📜  const char * 到 std::wstring - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:53.874000             🧑  作者: Mango

代码示例1
std::wstring s2ws(const std::string& str)
{
    int size_needed = MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0);
    std::wstring wstrTo( size_needed, 0 );
    MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), &wstrTo[0], size_needed);
    return wstrTo;
}