-
Notifications
You must be signed in to change notification settings - Fork 75
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
Support printing unicode characters on windows #449
base: master
Are you sure you want to change the base?
Conversation
@ahaoboy Can you try this branch to check that it works for you? All works as expected for me locally, but good to double-check |
Cool~ It works! |
We might want to add an alternative function |
@chqrlie Do you have any objections? |
} | ||
MultiByteToWideChar(CP_UTF8, 0, str, len, wstr, wlen); | ||
wstr[wlen] = L'\0'; | ||
WriteConsoleW(hConsole, wstr, wlen, &written, NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this work?
DWORD prev = GetConsoleOutputCP();
SetConsoleOutputCP(CP_UTF8);
WriteConsoleA(hConsole, str, len, &written, NULL);
SetConsoleOutputCP(prev);
Maybe you don't even need to use WriteConsoleA:
DWORD prev = GetConsoleOutputCP();
SetConsoleOutputCP(CP_UTF8);
fwrite(str, 1, len, con);
SetConsoleOutputCP(prev);
From #447, Unicode characters are not correctly printed to the console with
console.log
in some cases