Fixed some UnicodeEncodeError exceptions that could occur with Python 2.

This commit is contained in:
Adam Waldenberg 2013-05-13 02:58:14 +02:00
parent 99dc2c4735
commit 35214550f3

View file

@ -45,12 +45,16 @@ class FileDiff:
@staticmethod @staticmethod
def get_extension(string): def get_extension(string):
string = string.encode("utf-8", "replace")
string = string.decode("utf-8", "replace")
string = string.split("|")[0].strip().strip("{}").strip("\"").strip("'") string = string.split("|")[0].strip().strip("{}").strip("\"").strip("'")
string = codecs.getdecoder('unicode_escape')(string.strip())[0] string = codecs.getdecoder('unicode_escape')(string.strip())[0]
return os.path.splitext(string)[1][1:] return os.path.splitext(string)[1][1:]
@staticmethod @staticmethod
def get_filename(string): def get_filename(string):
string = string.encode("utf-8", "replace")
string = string.decode("utf-8", "replace")
string = string.split("|")[0].strip().strip("{}").strip("\"").strip("'") string = string.split("|")[0].strip().strip("{}").strip("\"").strip("'")
return codecs.getdecoder('unicode_escape')(string.strip())[0] return codecs.getdecoder('unicode_escape')(string.strip())[0]