This is an archive of the discontinued LLVM Phabricator instance.

[Windows] Set the console output page to UTF-8
AbandonedPublic

Authored by rnk on Feb 7 2018, 2:11 PM.

Details

Reviewers
zturner
Summary

Remove the Windows-specific logic that restricted us to printing only
printable ASCII characters. Use the normal UTF-8 isPrintable check
instead.

Fixes PR36267.

It's possible that older versions of the Windows console don't handle
CP_UTF8 correctly, but I think it's better to print UTF-8 for users of
modern OSs and gibberish on older installs.

Event Timeline

rnk created this revision.Feb 7 2018, 2:11 PM
rnk abandoned this revision.Feb 7 2018, 2:39 PM

Maybe we shouldn't do this, I wrote in the bug:

Unfortunately, it sounds like forcibly setting the user's console to the UTF8 codepage is hostile: https://github.com/stedolan/jq/issues/1121 Apparently it can cause window resizing, and I was able to confirm that the setting persists after exiting clang, which is really unclean. I want a solution where clang just prints UTF-8 and it works.

amccarth added inline comments.
llvm/lib/Support/Windows/Process.inc
273

I agree that we should _not_ change the console's code page, but if we do, we should make an effort to change it back. That would still be less than ideal if the program crashes, and you might have two resize events.