Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fifteenzhang opened this issue Jul 9, 2020 · 1 comment
Open

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

fifteenzhang opened this issue Jul 9, 2020 · 1 comment

Comments

@fifteenzhang
Copy link

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

@NoonLeu
Copy link

NoonLeu commented May 10, 2021

#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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants