From abaf3060bde318f5e98c1af87593871e3b5e275b Mon Sep 17 00:00:00 2001
From: Peter Landgren <peter.talken@telia.com>
Date: Thu, 16 Sep 2010 12:33:23 +0000
Subject: [PATCH] Issue 4212, Win problems with media path/file name with non
 latin.

svn: r15905
---
 src/Utils.py | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/Utils.py b/src/Utils.py
index e2809088a..b6744544a 100644
--- a/src/Utils.py
+++ b/src/Utils.py
@@ -37,6 +37,8 @@ import random
 import time
 import shutil
 import uuid
+import logging
+LOG = logging.getLogger(".")
 
 #-------------------------------------------------------------------------
 #
@@ -333,11 +335,24 @@ def get_unicode_path(path):
     :rtype:      unicode
     :returns:     The Unicode version of path.
     """
-    # Don't make unicode of unicode as this does not work
-    # with parameter for encoding.
-    if type(path) == type(u""):
+    # Don't make unicode of unicode
+    if isinstance(path, unicode):
         return path
-    return unicode(path,sys.getfilesystemencoding())
+
+    if constfunc.win():
+        # in windows filechooser returns officially utf-8, not filesystemencoding
+        try:
+            return unicode(path)
+        except:
+            LOG.warn("Problem encountered converting string: %s." % path)
+            return unicode(path, sys.getfilesystemencoding(), errors='replace')
+    else:
+        try:
+            return unicode(path, sys.getfilesystemencoding())
+        except:
+            LOG.warn("Problem encountered converting string: %s." % path)
+            return unicode(path, sys.getfilesystemencoding(), errors='replace')    
+
 
 
 #-------------------------------------------------------------------------