From b3a739757b0c6246514e6ebc9bc02961bfa9ad15 Mon Sep 17 00:00:00 2001 From: Guillaume Chazarain Date: Sun, 26 May 2013 19:21:28 +0200 Subject: [PATCH] Python3 can print UTF-8 to curses, python2 can't so let's handle both. --- iotop/ui.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/iotop/ui.py b/iotop/ui.py index a104114..18ef227 100644 --- a/iotop/ui.py +++ b/iotop/ui.py @@ -472,7 +472,14 @@ class IOTopUI(object): num_lines = min(len(lines), self.height - 2 - int(bool(status_msg))) for i in range(num_lines): try: - self.win.addstr(i + len(summary) + 1, 0, lines[i]) + def print_line(line): + self.win.addstr(i + len(summary) + 1, 0, line) + try: + print_line(lines[i]) + except UnicodeEncodeError: + # Python2: 'ascii' codec can't encode character ... + # http://bugs.debian.org/708252 + print_line(lines[i].encode('utf-8')) except curses.error: pass if status_msg: -- 2.11.4.GIT