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("'")
|
return check("'")
|
||||||
if ent == 'hellips':
|
if ent == 'hellips':
|
||||||
ent = 'hellip'
|
ent = 'hellip'
|
||||||
if ent.lower().startswith(u'#x'):
|
if ent.startswith('#'):
|
||||||
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'#'):
|
|
||||||
try:
|
try:
|
||||||
num = int(ent[1:])
|
if ent[1] in ('x', 'X'):
|
||||||
except ValueError:
|
num = int(ent[2:], 16)
|
||||||
|
else:
|
||||||
|
num = int(ent[1:])
|
||||||
|
except:
|
||||||
return '&'+ent+';'
|
return '&'+ent+';'
|
||||||
if encoding is None or num > 255:
|
if encoding is None or num > 255:
|
||||||
return check(my_unichr(num))
|
return check(my_unichr(num))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user