This method is used only to convert string where characters are within ASCII character set. I don't know for method where characters like ü can be converted to something within ASCII character set. Maybe there is some third party library but I don't know.
Thanks a lot. It solves my problem.
ReplyDeleteChangsong
Very neat code !! Solved my problem. Many Thanks
ReplyDeleteThis causes problems with accented characters.
ReplyDeleteFor example, try converting "Música" from std::string to std::wstring
obviously that wont work. You can only go from wstring to string if the wstring only contains ASCII characters
ReplyDeleteso how does one convert accented strings from multibyte to unicode?
ReplyDeleteThanks it is working. But I create a std::string like this.
ReplyDeletestd::string s("response_brücke");
and convert it like this
std::wstring ws;
ws.assign(s.begin(), s.end());
But the value of ws is not correct.
How can we convert the value of "s" into "ws".
This method is used only to convert string where characters are within ASCII character set. I don't know for method where characters like ü can be converted to something within ASCII character set. Maybe there is some third party library but I don't know.
ReplyDeleteThanks, I got the solution
ReplyDeletestd::wstringstream ws;
ws << s.c_str();
std::wstring sLogLevel = ws.str();
Thanks a lot. Nowhere else I found such clean and properly working solution. I found it very useful.
ReplyDeleteThanks a lot. This solved my problem too!
ReplyDeleteVery good.
ReplyDeleteA little bit more compact:
// std::string -> std::wstring
std::string s("string");
std::wstring ws(s.begin(), s.end()); // uses a constructor! :-)
Searched a long time for this trying to convert nordic characters Å Ä Ö from string to wstring. This solved it!
ReplyDeleteyes it is best command...go here
ReplyDelete