From de270d83eede0016b987b3cb11d26cc1a7698df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sat, 22 Sep 2012 20:23:43 +0200 Subject: [PATCH] setup utf8 output encoding --- moin2doku.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/moin2doku.py b/moin2doku.py index 3ab7887..827784c 100755 --- a/moin2doku.py +++ b/moin2doku.py @@ -227,6 +227,15 @@ def convertfile(pagedir, output = None, overwrite = False): # # "main" starts here # + +# setup utf8 output +if sys.stdout.isatty(): + default_encoding = sys.stdout.encoding +else: + import locale + default_encoding = locale.getpreferredencoding() +sys.stdout = codecs.getwriter(default_encoding)(sys.stdout); + try: opts, args = getopt.getopt(sys.argv[1:], 'hfad:F:r:', [ "help" ]) except getopt.GetoptError, e: