From 4f23af98da1085f35f400b43c32ff64f1e2b53e4 Mon Sep 17 00:00:00 2001 From: Alex Dedul Date: Thu, 26 Jul 2007 17:35:32 +0000 Subject: [PATCH] Try to properly handle utf-8 and latin-1 encoded client names in the peers tab. --- src/interface.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/interface.py b/src/interface.py index b2f622a23..03cf98e25 100644 --- a/src/interface.py +++ b/src/interface.py @@ -1022,9 +1022,16 @@ class DelugeGTK: izip(peer["ip"].split("."), (24, 16, 8, 0))]) + client = peer["client"] + try: + client = client.decode('utf-8') + except UnicodeDecodeError: + # Fallback to latin-1 in case peer's client + # doesn't use utf-8. utorrent < 1.7 for example + client = client.decode('latin-1') + iter = self.peer_store.append([ip_int, peer["ip"], - unicode(peer["client"], "latin-1"), - round(peer["peer_has"], 2), + client, round(peer["peer_has"], 2), peer["download_speed"], peer["upload_speed"]])