📌  相关文章
📜  如何在 C++ 代码示例中将字符串转换为 wchar_t

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

代码示例1
std::wstring s2ws(const std::string& s)
{
    int len;
    int slength = (int)s.length() + 1;
    len = MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, 0, 0);
    wchar_t* buf = new wchar_t[len];
    MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, buf, len);
    std::wstring r(buf);
    delete[] buf;
    return r;
}