From 8d95a424b005754e7a565f70624d8ff155809327 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Mon, 13 May 2013 10:51:24 +0200 Subject: [PATCH] Fix fetch of RSS feeds containing unicode. --- src/utils/str.py | 6 +++++- src/utils/web.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/utils/str.py b/src/utils/str.py index e411eacf0..d1f1b0f31 100644 --- a/src/utils/str.py +++ b/src/utils/str.py @@ -450,7 +450,11 @@ def format(s, *args, **kwargs): def sub(match): char = match.group(1) if char == 's': - return str(args.pop()) + token = args.pop() + if isinstance(token, unicode) or isinstance(token, str): + return token + else: + return unicode(token) elif char == 'i': # XXX Improve me! return str(args.pop()) diff --git a/src/utils/web.py b/src/utils/web.py index d550ecdef..da8d6521b 100644 --- a/src/utils/web.py +++ b/src/utils/web.py @@ -180,7 +180,7 @@ class HtmlToText(HTMLParser, object): self.data.append(data) def handle_entityref(self, data): - self.data.append(chr(htmlentitydefs.name2codepoint[data])) + self.data.append(unichr(htmlentitydefs.name2codepoint[data])) def getText(self): text = ''.join(self.data).strip()