Fix #2086237 [LookupError: unknown encoding mac-centraleurope](https://bugs.launchpad.net/calibre/+bug/2086237)

This commit is contained in:
Kovid Goyal 2024-11-01 09:35:15 +05:30
parent 3e96e1375f
commit afb2610676
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -100,7 +100,7 @@ def find_declared_encoding(raw, limit=50*1024):
return ans
_CHARSET_ALIASES = {"macintosh" : "mac-roman", "x-sjis" : "shift-jis"}
_CHARSET_ALIASES = {"macintosh" : "mac-roman", "x-sjis" : "shift-jis", 'mac-centraleurope': 'cp1250'}
def detect(bytestring):
@ -108,6 +108,7 @@ def detect(bytestring):
bytestring = bytestring.encode('utf-8', 'replace')
from calibre_extensions.uchardet import detect as implementation
enc = implementation(bytestring).lower()
enc = _CHARSET_ALIASES.get(enc, enc)
return {'encoding': enc, 'confidence': 1 if enc else 0}