From fb6bceed8c1c32929e1d024b2ce43b945026fe83 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Mon, 1 Mar 2010 20:37:37 +0100 Subject: Decode text to utf-8 when previewing. --- pastepy.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pastepy.py b/pastepy.py index 9ad21de..2485c2c 100644 --- a/pastepy.py +++ b/pastepy.py @@ -63,9 +63,9 @@ class Paste(object): def preview(self, mp): try: - lex = get_lexer_by_name(mp['syntax'].value) + lex = get_lexer_by_name(mp['syntax'].value.decode('utf8')) lexername = lex.name - text = highlight(mp['text'].value, lex, self.formatter) + text = highlight(mp['text'].value.decode('utf8'), lex, self.formatter) except: return self.message('Could not find the lexer "%s".' % mp['syntax'].value, 'Error') @@ -75,9 +75,9 @@ class Paste(object): 'header': '%s – Preview' % settings.pastebin_name, 'hash': None, 'date': datetime.datetime.utcnow().ctime(), - 'nick': mp['nick'].value or 'Anoynmous', + 'nick': mp['nick'].value.decode('utf8') or 'Anoynmous', 'syntax': lexername, - 'pastetitle': mp['title'].value or 'Untitled', + 'pastetitle': mp['title'].value.decode('utf8') or 'Untitled', 'text': text, }))] -- cgit v1.2.3