From 03ccb32946582a4f638d82623a9b632e9c0173d7 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 17 Oct 2008 21:30:28 +0200 Subject: [PATCH] Allow specifying a non-utf8 encoding. Signed-off-by: Miklos Vajna --- darcs2git.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/darcs2git.py b/darcs2git.py index a3e8f6f..cbcd784 100755 --- a/darcs2git.py +++ b/darcs2git.py @@ -145,6 +145,12 @@ This program comes with NO WARRANTY. don\'t clean conversion repo; test end result.""") + p.add_option ('-e', '--encoding', action='store', + type='string', + default='UTF-8', + nargs=1, + help='specify encoding, for example ISO-8859-2') + global options options, args = p.parse_args () if not args: @@ -280,7 +286,7 @@ class InventoryPatch: if self.inverted: inv = '-' - return unicode('%s%s*%s%s' % (self.name, self.author, inv, self.hash.split ('-')[0]), 'UTF-8') + return unicode('%s%s*%s%s' % (self.name, self.author, inv, self.hash.split ('-')[0]), options.encoding) @property def hash(self): @@ -592,7 +598,7 @@ class DarcsPatch: patch_name = '' try: name_elt = self.xml.getElementsByTagName ('name')[0] - patch_name = unicode(fix_braindead_darcs_escapes(str(name_elt.childNodes[0].data)), 'UTF-8') + patch_name = unicode(fix_braindead_darcs_escapes(str(name_elt.childNodes[0].data)), options.encoding) except IndexError: pass return patch_name -- 2.11.4.GIT