Spell check: Fix using non UTF-8 dictionaries broken in calibre 5

This commit is contained in:
Kovid Goyal 2020-10-17 21:45:34 +05:30
parent c9fb373216
commit 40e5b7124f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -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: