mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Spell check: Fix using non UTF-8 dictionaries broken in calibre 5
This commit is contained in:
parent
c9fb373216
commit
40e5b7124f
@ -46,8 +46,8 @@ def parse_xcu(raw, origin='%origin%'):
|
|||||||
def convert_to_utf8(dic_data, aff_data, errors='strict'):
|
def convert_to_utf8(dic_data, aff_data, errors='strict'):
|
||||||
m = re.search(br'^SET\s+(\S+)$', aff_data[:2048], flags=re.MULTILINE)
|
m = re.search(br'^SET\s+(\S+)$', aff_data[:2048], flags=re.MULTILINE)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
enc = m.group(1)
|
enc = m.group(1).decode('ascii', 'replace')
|
||||||
if enc.upper() not in (b'UTF-8', b'UTF8'):
|
if enc.upper() not in ('UTF-8', 'UTF8'):
|
||||||
try:
|
try:
|
||||||
codecs.lookup(enc)
|
codecs.lookup(enc)
|
||||||
except LookupError:
|
except LookupError:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user