Convert const char* to const wchar_t*

后端 未结 3 1303
有刺的猬
有刺的猬 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:06

    You can use mbstowcs:

        wchar_t WBuf[100];
        mbstowcs(WBuf,lua_tostring( /*...*/ ),99);
    

    or more safe:

        const char* sz = lua_tostring(/*...*/);
        std::vector vec;
        size_t len = strlen(sz);
        vec.resize(len+1);
        mbstowcs(&vec[0],sz,len);
        const wchar_t* wsz = &vec[0];
    

提交回复
热议问题