diff --git a/lesscompiler.py b/lesscompiler.py index 90b2181..4d33063 100644 --- a/lesscompiler.py +++ b/lesscompiler.py @@ -164,6 +164,11 @@ def convertLess2Css(self, lessc_command, dirs, file='', minimised=True, outputFi if not lessc_command: lessc_command = "lessc" + # by trying it on both OSX and Windows this seems to be the combination that works + if sys.version_info < (3, 0, 0) and platform.system() is 'Windows': + less = less.encode(sys.getfilesystemencoding()) + css = css.encode(sys.getfilesystemencoding()) + # get the name of the platform (ie are we running on windows) platform_name = platform.system() # check if the compiler should create a minified CSS file @@ -240,8 +245,8 @@ def parseBaseDirs(self, base_dir='./', output_dir=''): fn = self.view.file_name() # in Python 3 all string are Unicode by default, we only have to encode when running on something lower than 3 # in addition Windows uses UTF-16 for its file names so we don't encode to UTF-8 on Windows - if sys.version_info < (3, 0, 0) and not platform.system() is "Windows": - fn = fn.encode("utf_8") + if sys.version_info < (3, 0, 0): # and not platform.system() is "Windows": + fn = fn.encode(sys.getfilesystemencoding()) # get the folder of the current file file_dir = os.path.dirname(fn) @@ -281,6 +286,11 @@ def parseBaseDirs(self, base_dir='./', output_dir=''): proj_folders = window.folders() # loop through all the top level folders in the project for folder in proj_folders: + # there was a problem when fn contains a special char like é. An error would + # occur when checking if fn starts with the folder. Converting folder to utf_8 + # seems to fix this error + if sys.version_info < (3, 0, 0): # and not platform.system() is 'Windows': + folder = folder.encode(sys.getfilesystemencoding()) # we will have found the project folder when it matches with the start of the current file name if fn.startswith(folder): # keep the current folder as the project folder