How can i convert UTF-8 encoded std::string to UTF-16 std::string? Is it possible?
And no, i can\'t use std::wstring in my case.
Windows, MSVC-11.0.
How about trying like this:-
std::string s = u8"Your string";
// #include
std::wstring_convert,char16_t> convert;
std::u16string u16 = convert.from_bytes(s);
std::string u8 = convert.to_bytes(u16);
Also check this for UTF to UTF conversion.
From the docs:-
The specialization codecvt converts between the UTF-16 and UTF-8 encoding schemes, and the specialization codecvt converts between the UTF-32 and UTF-8 encoding schemes.