aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThibaut Horel <thibaut.horel@gmail.com>2014-08-13 02:35:17 -0400
committerThibaut Horel <thibaut.horel@gmail.com>2014-08-13 02:35:17 -0400
commita4ea3606267b8e8606b9eabf25940c3366bf679c (patch)
treeb527779c2275658976fc1d8dd11d36e30a03dfef
parent780ccba33c8b4e71cea79baacac04e357da59f67 (diff)
downloadtabletext-a4ea3606267b8e8606b9eabf25940c3366bf679c.tar.gz
Fix unicode error when printing to unicode unaware output
-rw-r--r--tabletext.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/tabletext.py b/tabletext.py
index c9412a4..1245d26 100644
--- a/tabletext.py
+++ b/tabletext.py
@@ -3,7 +3,7 @@ from __future__ import unicode_literals
import re
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
import sys
-from codecs import open
+from codecs import open, getwriter
from itertools import izip_longest
@@ -58,6 +58,7 @@ def add_width(format_string, width):
def print_table(table, formats=None, padding=(1, 1), corners="┌┬┐├┼┤└┴┘",
header_corners="╒╤╕╞╪╡", header_hor="═", header_ver="│",
header=False, hor="─", ver="│"):
+ sys.stdout = getwriter('utf8')(sys.stdout)
if not formats:
formats = [""] * len(table[-1])
elif type(formats) is unicode: