Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何将 std::string(mysql 选择查询的结果)转换为 WCHAR?
已经尝试过这个:
(wchar_t)app->db->getString("CharName")
但我得到错误
不存在从 std::string 到 wchar_t 的合适对话
如果您有 C++11,请使用std::wstring_convert:
std::wstring_convert
#include <locale> std::wstring_convert<std::codecvt<wchar_t, char, std::mbstate_t>> converter; std::wstring result = converter.from_bytes(app->db->getString("CharName"));
如果没有,您可以求助于 C 函数,mbstowcs()并转换为适当的标准字符串类型。
mbstowcs()