Created
May 3, 2016 04:43
-
-
Save dmahugh/4a741bea64f8eac94676cf31124059e4 to your computer and use it in GitHub Desktop.
enabling Unicode support in VS Code's console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you're scanning the file system in Python, you will eventually come across filenames | |
# that can't be displayed in the VS Code console because they contain characters that | |
# will raise a UnicodeDecode Error. Opening sys.stdout as shown below fixes this problem. | |
# this ensures the console will handle Unicode characters | |
import sys | |
sys.stdout = open(sys.stdout.fileno(), mode='w', encoding='utf8', buffering=1) | |
# the following print() statement crashes in the VS Code console window with a | |
# UnicodeDecodeError if you DON'T set sys.stdout as shown above | |
print('A few Unicode characters: ® Σ Α Π Φ Ω') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment