From 14ce9970ad413dad9461d87adb08c00f06b868b0 Mon Sep 17 00:00:00 2001 From: Jarrod Johnon Date: Tue, 20 Jan 2015 16:11:16 -0500 Subject: [PATCH] Fix unicode error on stdout piping When confetty runs in a UTF-8 terminal, things are fine. However python assumes ascii only when piped. Catch the situation and force utf-8 encoding rather than erroring out in such a circumstance --- confluent_client/bin/confetty | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/confluent_client/bin/confetty b/confluent_client/bin/confetty index fd3f69b0..cc22e16d 100755 --- a/confluent_client/bin/confetty +++ b/confluent_client/bin/confetty @@ -258,7 +258,10 @@ def print_result(res): output = '{0:<40} {1:>39}'.format(attrstr, notestr) else: output = attrstr - print(output) + try: + print(output) + except UnicodeDecodeError: + print(output.encode('utf-8')) def do_command(command, server):