mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Improve encoding detection.
This commit is contained in:
parent
f94102bc87
commit
dc11f5051f
@ -344,7 +344,10 @@ def entity_to_unicode(match, exceptions=[], encoding='cp1252'):
|
||||
num = int(ent[1:])
|
||||
if encoding is None or num > 255:
|
||||
return unichr(num)
|
||||
return chr(num).decode(encoding)
|
||||
try:
|
||||
return chr(num).decode(encoding)
|
||||
except UnicodeDecodeError:
|
||||
return unichr(num)
|
||||
try:
|
||||
return unichr(name2codepoint[ent])
|
||||
except KeyError:
|
||||
|
Loading…
x
Reference in New Issue
Block a user