1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-13 17:16:23 +01:00

add exception if encoding fails and try ISO-8859-1

In some rare cases the chardet encoding detection detects
a wrong encoding standard. Then we switch to latin-1 which
covers most if utf-8 does not work.
This commit is contained in:
lethliel 2019-04-16 14:40:13 +02:00
parent 71770555ac
commit 5841bf759f

View File

@ -61,5 +61,9 @@ def decode_it(obj):
import chardet
return obj.decode(chardet.detect(obj)['encoding'])
except:
import locale
return obj.decode(locale.getlocale()[1])
try:
import locale
return obj.decode(locale.getlocale()[1])
except:
return obj.decode('latin-1')