Use unichr() instead of chr() with Python 2.

This commit is contained in:
Andrea Corbellini 2015-09-22 20:52:30 +02:00
commit c255a35800
2 changed files with 14 additions and 2 deletions

View file

@ -499,14 +499,14 @@ class _HTMLWordTruncator(HTMLParser):
except KeyError:
self.handle_ref('')
else:
self.handle_ref(chr(codepoint))
self.handle_ref(six.unichr(codepoint))
def handle_charref(self, name):
if name.startswith('x'):
codepoint = int(name[1:], 16)
else:
codepoint = int(name)
self.handle_ref(chr(codepoint))
self.handle_ref(six.unichr(codepoint))
def truncate_html_words(s, num, end_text='...'):