The following code fails and I can't seem to figure out why.
std::string s = "–";
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
std::wstring wide = converter.from_bytes(s);
I tried reading up on UTF-8, but I couldn't figure it out. Storing the initial string as a wstring, converting it to a string then converting it back gives the correct result.
std::wstring ws = L"–";
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
std::string narrow = converter.to_bytes(ws);
std::wstring wide = converter.from_bytes(narrow);