diff --git a/changes.py b/changes.py index b65bf45..b1a7147 100644 --- a/changes.py +++ b/changes.py @@ -18,6 +18,7 @@ # along with gitinspector. If not, see . from __future__ import print_function +from __future__ import unicode_literals from outputable import Outputable import codecs import extensions diff --git a/gitinspector.py b/gitinspector.py index e42c7cd..f061790 100755 --- a/gitinspector.py +++ b/gitinspector.py @@ -50,6 +50,7 @@ class Runner: def output(self): terminal.skip_escapes(not sys.stdout.isatty()) + terminal.set_stdout_encoding() previous_directory = os.getcwd() os.chdir(self.repo) format.output_header() diff --git a/terminal.py b/terminal.py index 3a6ddd1..69e4c02 100644 --- a/terminal.py +++ b/terminal.py @@ -18,6 +18,7 @@ # along with gitinspector. If not, see . from __future__ import print_function +import codecs import os import platform import sys @@ -101,3 +102,7 @@ def get_size(): return (width, height) return (80, 25) + +def set_stdout_encoding(): + if not sys.stdout.isatty() and sys.version_info < (3,): + sys.stdout = codecs.getwriter('utf-8')(sys.stdout)