]> wagner.pp.ru Git - oss/ljdump.git/commitdiff
automatically fall back to Latin-1 for old entries that aren't UTF-8
authorGreg Hewgill <greg@hewgill.com>
Sat, 10 Jan 2009 01:45:01 +0000 (14:45 +1300)
committerGreg Hewgill <greg@hewgill.com>
Sat, 10 Jan 2009 01:45:01 +0000 (14:45 +1300)
ChangeLog
ljdump.py

index bc062fd440b70e8e0f7248c07b89efe2789931a7..ba273d090557a3703e0cd1312a8466cb2f426e14 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@ ChangeLog - ljdump
 Version 1.3.3 - 2009-01-10
 
 - Feature: ljdump now prompts for login info if ljdump.config does not exist
+- Bugfix: Automatically handle UnicodeDecodeError for old entries
 
 Version 1.3.2 - 2009-01-09
 
index a6d7db39ec0bc166639d87b8324ccc393332e9b7..6a7e3a2655ff67d88814066c10332d17ef36c788 100755 (executable)
--- a/ljdump.py
+++ b/ljdump.py
@@ -74,7 +74,11 @@ def dumpelement(f, name, e):
         if isinstance(e[k], {}.__class__):
             dumpelement(f, k, e[k])
         else:
-            s = unicode(str(e[k]), "UTF-8")
+            try:
+                s = unicode(str(e[k]), "UTF-8")
+            except UnicodeDecodeError:
+                # fall back to Latin-1 for old entries that aren't UTF-8
+                s = unicode(str(e[k]), "cp1252")
             f.write("<%s>%s</%s>\n" % (k, saxutils.escape(s), k))
     f.write("</%s>\n" % name)