From: Oleg Broytman Date: Sat, 22 Dec 2007 20:52:14 +0000 (+0000) Subject: Do not encode non-encodeable entities. X-Git-Tag: v4.5.3~252 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=95b39d3b8b276f64c706c253c6ee643bf93725aa;p=bookmarks_db.git Do not encode non-encodeable entities. git-svn-id: file:///home/phd/archive/SVN/bookmarks_db/trunk@124 fdd5c36f-1aea-0310-aeeb-c58d7e2b6c23 --- diff --git a/Robots/parse_html.py b/Robots/parse_html.py index c5c9eb6..666c707 100755 --- a/Robots/parse_html.py +++ b/Robots/parse_html.py @@ -30,7 +30,10 @@ def recode_entities(title, charset): output = [] for part in entity_re.split(title): if entity_re.match(part): - part = unichr(int(part[2:-1])).encode(charset, "replace") + try: + part = unichr(int(part[2:-1])).encode(charset) + except UnicodeEncodeError: + pass # Leave the entity as is output.append(part) return ''.join(output)