Skip to content

Commit

Permalink
Unicode support in Windows and Python 2.7
Browse files Browse the repository at this point in the history
Use win-unicode-console to install various fixes needed in Python 2 on
Windows: display of Unicode characters in Windows console, use of unicode
in sys.argv, etc...

See https://pypi.org/project/win_unicode_console/ for more details.
  • Loading branch information
sevein committed Apr 12, 2021
1 parent cea9d53 commit 6a83a69
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions fido/fido.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from argparse import ArgumentParser, RawTextHelpFormatter
from contextlib import closing
import os
import platform
import re
import sys
import tarfile
Expand All @@ -25,6 +26,7 @@
from xml.etree import cElementTree as ET
import zipfile

from six import PY2
from six.moves import range

from fido import __version__, CONFIG_DIR
Expand Down Expand Up @@ -751,7 +753,16 @@ def list_files(roots, recurse=False):
break


def set_up_platform():
"""Enable Unicode display when running Python from Windows console."""
if platform.system() == 'Windows' and PY2:
import win_unicode_console # noqa: E402
win_unicode_console.enable(use_unicode_argv=True)


def main(args=None):
set_up_platform()

if not args:
args = sys.argv[1:]

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def find_version(*file_paths):
install_requires = [
'olefile >= 0.46, < 1',
'six >= 1.10.0, < 2',
'win-unicode-console >= 0.5; python_version == "2.7" and platform_system == "Windows"',
]


Expand Down

0 comments on commit 6a83a69

Please sign in to comment.