Convert const char* to const wchar_t*

后端 未结 3 1304
有刺的猬
有刺的猬 2021-02-09 08:30

I am trying to create a program with Irrlicht that loads certain things from a configuration file written in Lua, one of which is the window title. However, the lua_tostri

3条回答
  •  生来不讨喜
    2021-02-09 09:03

    For Unicode:

    std::string myString = "Master James";
    const char* sz = myString.c_str();
    size_t origsizes = strlen(sz) + 1;
    const size_t newsizes = 500;
    size_t convertedCharP = 0;
    wchar_t constTowchar[500];
    mbstowcs_s(&convertedCharP, constTowchar, origsizes, sz, _TRUNCATE);
    std::wcout << constTowchar << std::endl;
    

    This is working using mbstowcs_s.

提交回复
热议问题