From df7dfe38599f257f4493d06cdda086cdc31196c3 Mon Sep 17 00:00:00 2001 From: tonio Date: Thu, 13 Jan 2011 15:53:34 +0100 Subject: [PATCH] fixed #114 Falling back to automated decoding in case of an unknown charset. --- lib/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/__init__.py b/lib/__init__.py index 88534b2ce..476e28a3e 100644 --- a/lib/__init__.py +++ b/lib/__init__.py @@ -101,7 +101,10 @@ def ajax_response(request, status="ok", url=None, template=None, **kwargs): def decode(s, encodings=('utf8', 'latin1', 'windows-1252', 'ascii'), charset=None): if charset is not None: - return s.decode(charset, 'ignore') + try: + return s.decode(charset, 'ignore') + except LookupError: + pass for encoding in encodings: try: