528: Support multi character encodings by CSV

ohac****@gmai***** (Google Code) (Is this you? Claim this profile.)
July 8, 2008
I'd like to use multiple character encodings.
This patch handles the setting as CSV.
diff --git a/diffviewer/diffutils.py b/diffviewer/diffutils.py
--- a/diffviewer/diffutils.py
+++ b/diffviewer/diffutils.py
@@ -189,7 +189,13 @@
             u = unicode(s, 'utf-8')
             return u
         except UnicodeError:
-            u = unicode(s, enc)
+            for e in enc.split(','):
+                try:
+                    print enc
+                    u = unicode(s, enc)
+                    break
+                except UnicodeError:
+                    pass
             return u.encode('utf-8')
     else:
         raise TypeError("Value to convert is unexpected type %s", type(s))
#1 ohac****@gmai***** (Google Code) (Is this you? Claim this profile.)
Sorry, the patch file was incorrect.
  • +
    diff --git a/diffviewer/diffutils.py b/diffviewer/diffutils.py
    --- a/diffviewer/diffutils.py
    +++ b/diffviewer/diffutils.py
    @@ -189,7 +189,12 @@
                 u = unicode(s, 'utf-8')
                 return u
             except UnicodeError:
    -            u = unicode(s, enc)
    +            for e in enc.split(','):
    +                try:
    +                    u = unicode(s, e)
    +                    break
    +                except UnicodeError:
    +                    pass
                 return u.encode('utf-8')
         else:
             raise TypeError("Value to convert is unexpected type %s", type(s))
chipx86
#2 chipx86
Can you submit this on http://reviews.review-board.org/ ?
#3 ohac****@gmai***** (Google Code) (Is this you? Claim this profile.)
OK, Submitted http://reviews.review-board.org/r/434/
david
#4 david
Fixed in SVN revision 1392.
  • +Fixed