string <-> wstring

1
2
3
4
5
6
7
8
9
10
11
12
#include <boost/locale.hpp>

int TestChangeWS()
{
// string -> wstring
std::wstring wname = boost::locale::conv::to_utf<wchar_t>(name, "GBK");
std::wcout << TEXT("wname:\t") << wname << TEXT("\n");
// wstring -> string
std::string sname = boost::locale::conv::from_utf(wname, "GBK");
std::cout << "sname:\t" << sname << "\n";
return 0;
}