From 61a859f3174967f7f4c27c595098c6b79312d541 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Sat, 13 Aug 2011 14:26:45 +0200 Subject: [PATCH] fall back to ISO encoding if UTF-8 gives an error --- util.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util.py b/util.py index 9a14469..b02bce9 100644 --- a/util.py +++ b/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