summaryrefslogtreecommitdiffstats
path: root/module/Utils.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-02-19 21:58:08 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-02-19 21:58:08 +0100
commit63f8af1fc3049527a4a4b53a1bbfde90cb4b2eb3 (patch)
tree8227674ebd87c28df53bad55de401a9264a283b4 /module/Utils.py
parentfixed cli unicode error (diff)
downloadpyload-63f8af1fc3049527a4a4b53a1bbfde90cb4b2eb3.tar.xz
encoding fixes
Diffstat (limited to 'module/Utils.py')
-rw-r--r--module/Utils.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/module/Utils.py b/module/Utils.py
index b023a981d..6f889118d 100644
--- a/module/Utils.py
+++ b/module/Utils.py
@@ -13,6 +13,13 @@ def chmod(*args):
except:
pass
+def decode(string):
+ """ decode string with utf if possible """
+ try:
+ return string.decode("utf8", "ignore")
+ except:
+ return string
+
def save_join(*args):
""" joins a path, encoding aware """
paths = []
@@ -21,6 +28,8 @@ def save_join(*args):
if i:
path = path.replace(":","")
+ path = decode(path)
+
tmp = path.encode(sys.getfilesystemencoding(), "replace")
paths.append(tmp)
return join(*paths)