fall back to ISO encoding if UTF-8 gives an error

This commit is contained in:
Helmut Merz 2011-08-13 14:26:45 +02:00
parent 2afb84f8b9
commit 61a859f317

View file

@ -77,7 +77,10 @@ def nl2br(text):
def toUnicode(value, encoding='UTF-8'):
if type(value) is not unicode:
return value.decode(encoding)
try:
return value.decode(encoding)
except UnicodeDecodeError:
return value.decode('ISO8859-15')
else:
return value