qmc-decoder icon indicating copy to clipboard operation
qmc-decoder copied to clipboard

WINDOWS下Console中日韩字符乱码问题

Open fifteenzhang opened this issue 5 years ago • 1 comments

最终输出结果正常,但console中的文件名是乱码

fifteenzhang avatar Jul 09 '20 01:07 fifteenzhang

#59 #59 //通过使用wstring和wcout来实现中日韩字符在Windows的console下正确输出 void sub_process(std::string dir) { std::wstring wdir; wdir.resize(("decode:"+dir).size()); int newSize = MultiByteToWideChar( CP_UTF8, 0, ("decode:"+dir).c_str(), static_cast(("decode:"+dir).length()), const_cast<wchar_t*>(wdir.c_str()), static_cast(wdir.size())); wdir.resize(newSize); std::wcout.imbue(std::locale("chs"));//wcout需要设置为“chs”字符集才能输出正确的字符 std::wcout << wdir << std::endl; std::string outloc(dir);

NoonLeu avatar May 10 '21 17:05 NoonLeu