mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #6305 (entity_to_unicode hexmess)
This commit is contained in:
parent
f3cfd09a54
commit
c9d31cb121
@ -413,15 +413,13 @@ def entity_to_unicode(match, exceptions=[], encoding='cp1252',
|
||||
return check("'")
|
||||
if ent == 'hellips':
|
||||
ent = 'hellip'
|
||||
if ent.lower().startswith(u'#x'):
|
||||
num = int(ent[2:], 16)
|
||||
if encoding is None or num > 255:
|
||||
return check(my_unichr(num))
|
||||
return check(chr(num).decode(encoding))
|
||||
if ent.startswith(u'#'):
|
||||
if ent.startswith('#'):
|
||||
try:
|
||||
if ent[1] in ('x', 'X'):
|
||||
num = int(ent[2:], 16)
|
||||
else:
|
||||
num = int(ent[1:])
|
||||
except ValueError:
|
||||
except:
|
||||
return '&'+ent+';'
|
||||
if encoding is None or num > 255:
|
||||
return check(my_unichr(num))
|
||||
|
Loading…
x
Reference in New Issue
Block a user