From c48e741a529670e55c6a88d2b67e5c78a3abc1f3 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Mon, 3 Apr 2017 16:14:08 +0200 Subject: [PATCH] fixed problem with Japanese colon (closes #95) --- lib/wttr.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/wttr.py b/lib/wttr.py index 35be522..cf51362 100644 --- a/lib/wttr.py +++ b/lib/wttr.py @@ -1,3 +1,5 @@ +# vim: set encoding=utf-8 + import gevent from gevent.wsgi import WSGIServer from gevent.queue import Queue @@ -106,9 +108,18 @@ def get_wetter(location, ip, html=False, lang=None, query=None, location_name=No stdout = "\n".join(stdout.splitlines()[:27]) + "\n" if query.get('no-caption', False): - first = stdout.splitlines()[0] + first = stdout.splitlines()[0].decode('utf-8') rest = stdout.splitlines()[1:] - stdout = "\n".join([first.split(':',1)[1].strip()] + rest) + "\n" + + separator = None + if ':' in first: + separator = ':' + if u':' in first: + separator = u':' + + if separator: + first = first.split(separator,1)[1] + stdout = "\n".join([first.strip().encode('utf-8')] + rest) + "\n" if query.get('no-terminal', False): stdout = remove_ansi(stdout)