How to convert wstring into string?

The question is how to convert wstring to string? I have next example : #include <string> #include <iostream> int main() { std::wstring ws = L”Hello”; std::string s( ws.begin(), ws.end() ); //std::cout <<“std::string = “<<s<<std::endl; std::wcout<<“std::wstring = “<<ws<<std::endl; std::cout <<“std::string = “<<s<<std::endl; } the output with commented out line is : std::string = Hello std::wstring = … Read more

std::wstring VS std::string

I am not able to understand the differences between std::string and std::wstring. I know wstring supports wide characters such as Unicode characters. I have got the following questions: When should I use std::wstring over std::string? Can std::string hold the entire ASCII character set, including the special characters? Is std::wstring supported by all popular C++ compilers? … Read more