From eb9fefc6483b558a3fdb5337ac46bd807882b62c Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Thu, 11 Jul 2013 03:50:39 -0400 Subject: [PATCH] Fix unicode bugs. --- commands/urbandictionary.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/commands/urbandictionary.py b/commands/urbandictionary.py index a527c00..04bdd09 100644 --- a/commands/urbandictionary.py +++ b/commands/urbandictionary.py @@ -30,11 +30,12 @@ class UrbanDictionary(Command): example = re.sub(r"\s+", " ", res['list'][0]['example']) if definition and definition[-1] not in (".", "!", "?"): definition += "." - msg = '{0} \x02Example\x0F: {1}'.format(definition, example) + msg = '{0} \x02Example\x0F: {1}'.format(definition.encode("utf8"), + example.encode("utf8")) self.reply(data, msg) elif res['result_type'] == 'fulltext': L = [i['word'] for i in res['list']] - msg = 'Here are some close matches: {0}.'.format(', '.join(L)) - self.reply(data, msg) + msg = 'Here are some close matches: {0}.' + self.reply(data, msg.format(u", ".join(L).encode("utf8")) else: self.reply(data, 'Sorry, no results found.')