-1

how can I convert a std::string (result from mysql select query) to WCHAR?

already tryed this:

(wchar_t)app->db->getString("CharName")

but I get error

no suitable conversation from std::string to wchar_t exists

1 Answers1

0

If you have C++11, use 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"));

If not, you can resort to C functions like mbstowcs() and convert to the appropriate standard string type.

David G
  • 94,763
  • 41
  • 167
  • 253