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

Fix UTF-8 console input/output on Windows #11557

Conversation

HertzDevil
Copy link
Contributor

Fixes #11527. Uses the chcp 65001 approach.

@HertzDevil HertzDevil added kind:feature platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:text labels Dec 9, 2021
@straight-shoota straight-shoota added this to the 1.3.0 milestone Dec 9, 2021
@HertzDevil
Copy link
Contributor Author

HertzDevil commented Dec 10, 2021

Minor note: the following will not work on Visual Studio Code by default:

> chcp 65001
Active code page: 65001

> crystal eval puts ×😂 | code -

The result would still be ×😂, which is the UTF-8 byte sequence reinterpreted in codepage 437. This is because VSCode picks up the system code page, not the one in the terminal session. This is not Crystal's fault and is unaffected by this PR. The following also produces garbled text:

> echo 😂 | code -

The workaround is to change the system code page as noted above, or set the VSCODE_CLI_ENCODING=UTF-8 environment variable.

@straight-shoota straight-shoota merged commit 4aabf4e into crystal-lang:master Dec 13, 2021
@HertzDevil HertzDevil deleted the feature/windows-console-utf8-output branch December 14, 2021 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:feature platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:text
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UTF-8 console I/O on Windows
3 participants