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:])
|
num = int(ent[1:])
|
||||||
if encoding is None or num > 255:
|
if encoding is None or num > 255:
|
||||||
return unichr(num)
|
return unichr(num)
|
||||||
return chr(num).decode(encoding)
|
try:
|
||||||
|
return chr(num).decode(encoding)
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
return unichr(num)
|
||||||
try:
|
try:
|
||||||
return unichr(name2codepoint[ent])
|
return unichr(name2codepoint[ent])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user