From 8d8e5738073d1726ace7d19589b9c6529b8b30ad Mon Sep 17 00:00:00 2001 From: RaNaN Date: Wed, 15 Jun 2011 18:53:49 +0200 Subject: fixes some encoding issues --- module/Utils.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'module/Utils.py') diff --git a/module/Utils.py b/module/Utils.py index cdf76c144..45fa81d52 100644 --- a/module/Utils.py +++ b/module/Utils.py @@ -43,10 +43,31 @@ def save_join(*args): path = decode(path) - tmp = path.encode(sys.getfilesystemencoding(), "replace") + tmp = fs_encode(path) paths.append(tmp) return join(*paths) +def fs_encode(string): + """ Encodes with filesystem encoding + + :param string: string to decode + :return: + """ + try: + return string.encode(sys.getfilesystemencoding(), "replace") + except: + return string + +def fs_decode(string): + """ Decodes with filesystem encoding + + :param string: string to decode + :return: + """ + try: + return string.decode(sys.getfilesystemencoding(), "replace") + except: + return string def compare_time(start, end): start = map(int, start) -- cgit v1.2.3