c++ - Cannot convert from utf16 little endian to utf8 -
desperately need help. "c:\temp\1 (2).txt" testing file in little endian utf16:
3c 00 64 00 69 00 76 00 3e 00 <div>
trying utf8 file following code:
#include <vector> #include <string> #include <locale> #include <codecvt> #include <vector> using std::string; using std::wstring; using std::vector; std::ifstream logfile("c:\\temp\\1 (2).txt", std::ios::binary); vector<char> paste_code_buf((std::istreambuf_iterator<char>(logfile)), (std::istreambuf_iterator<char>())); wstring paste_code; paste_code.assign(paste_code_buf.begin(), paste_code_buf.end()); std::wstring_convert < std::codecvt_utf8_utf16 < wchar_t, 0x10fffful, std::little_endian>> cv; string mbs = cv.to_bytes(paste_code);
looking @ mbs @ debugger ( visual studio 2013) shows no conversion has happened. what's wrong?
Comments
Post a Comment