简体   繁体   中英

How to do back conversion

In order to convert std::wstring to UTF-8 I use the following code:

std::wstring my_wide_string = L"my_sqlite_db.db";
std::wstring_convert<std::codecvt_utf8<wchar_t> > myconv;
myconv.to_bytes( my_wide_string.c_str() );

Now, I need to do a back conversion, ie UTF-8 to std::wstring .

What is the proper way to switch the converter?

Why not just use from_bytes() the reverse function:

std::wstring test = myconv.from_bytes(myutf8);

Live demo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM