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()