From 40e5b7124f9dd1bb69f2565aaec2190ad300ce53 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 17 Oct 2020 21:45:34 +0530 Subject: [PATCH] Spell check: Fix using non UTF-8 dictionaries broken in calibre 5 --- src/calibre/spell/import_from.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/spell/import_from.py b/src/calibre/spell/import_from.py index c4e9e4f106..916ce0b08d 100644 --- a/src/calibre/spell/import_from.py +++ b/src/calibre/spell/import_from.py @@ -46,8 +46,8 @@ def parse_xcu(raw, origin='%origin%'): def convert_to_utf8(dic_data, aff_data, errors='strict'): m = re.search(br'^SET\s+(\S+)$', aff_data[:2048], flags=re.MULTILINE) if m is not None: - enc = m.group(1) - if enc.upper() not in (b'UTF-8', b'UTF8'): + enc = m.group(1).decode('ascii', 'replace') + if enc.upper() not in ('UTF-8', 'UTF8'): try: codecs.lookup(enc) except LookupError: