From 95b39d3b8b276f64c706c253c6ee643bf93725aa Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sat, 22 Dec 2007 20:52:14 +0000 Subject: [PATCH] Do not encode non-encodeable entities. git-svn-id: file:///home/phd/archive/SVN/bookmarks_db/trunk@124 fdd5c36f-1aea-0310-aeeb-c58d7e2b6c23 --- Robots/parse_html.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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) -- 2.39.5