mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Handle spurious encoding match when detecting encoding for diff
This commit is contained in:
parent
2c9ca9ea7e
commit
cf01a5b969
@ -108,9 +108,11 @@ def get_decoded_raw(name):
|
||||
if syntax in {'html', 'xml'}:
|
||||
raw = xml_to_unicode(raw, verbose=True)[0]
|
||||
else:
|
||||
m = re.search(r"coding[:=]\s*([-\w.]+)", raw[:1024], flags=re.I)
|
||||
m = re.search(br"coding[:=]\s*([-\w.]+)", raw[:1024], flags=re.I)
|
||||
if m is not None and m.group(1) != '8bit':
|
||||
enc = m.group(1)
|
||||
if enc == b'unicode':
|
||||
enc = 'utf-8'
|
||||
else:
|
||||
enc = force_encoding(raw, verbose=True)
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user