fall back to ISO encoding if UTF-8 gives an error
This commit is contained in:
parent
2afb84f8b9
commit
61a859f317
1 changed files with 4 additions and 1 deletions
5
util.py
5
util.py
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue