The easiest way to convert a std::string
to a LPWSTR
is in my opinion:
std::string
to a std::vector<wchar_t>
wchar_t
in the vector.std::vector<wchar_t>
has a templated ctor which will take two iterators, such as the std::string.begin()
and .end()
iterators. This will convert each char to a wchar_t
, though. That's only valid if the std::string
contains ASCII or Latin-1, due to the way Unicode values resemble Latin-1 values. If it contains CP1252 or characters from any other encoding, it's more complicated. You'll then need to convert the characters.