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
1 changed files with 4 additions and 0 deletions

View File

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