[Solved] dae2egg and unicode

Hello,

In my application I’m trying to convert COLLADA files to EGG files using dae2egg, this way:

dae2egg = self.paths['urban_resource_folder'] / 'bin' / 'dae2egg.exe'
subprocess.call('%s -noexist -tbnall -o "%s" "%s"' % (dae2egg, egg_path, temp_collada_path))

My issue is that it is failing with path that contains unicode characters like French accent “é”.
With the original input path:

C:\Users\David\Documents\Projets\COLLADA\Bouclié.dae

I tried the following:

u'C:/Users/David/Documents/Projets/COLLADA/Boucli\xe9.dae'
u'C:/Users/David/Documents/Projets/COLLADA/Boucli\xc3\xa9.dae'

but none of those is working, I get an error:

Cannot find input file /c/Users/David/Documents/Projets/COLLADA/Boucli├â┬®.dae

But what surprises me is that it is working from a command shell:

C:\Users\David\Documents\Projets\COLLADA>dae2egg Bouclié.dae jojo.egg

Reading BoucliÚ.dae
Writing jojo.egg

Any idea what I should input in the subprocess call to make it work?

Thanks in advance
-David

Auto-solve:

cmd_line = '%s -noexist -tbnall -o "%s" "%s"' % (dae2egg, egg_path, temp_collada_path)
subprocess.call(cmd_line.encode(locale.getdefaultlocale()[1]))

But now it’s failing in the loadModel, see this post:
[url]loader.loadModel and unicode]

Any chance to see this fixed?
For now I still use the DOS 8.3 trick, and it works.

For those who would need the code:

path = os.path.normpath(path)
import win32api
path = win32api.GetShortPathName(path) #convert to DOS 8.3 for loadModel for instance
return Filename.fromOsSpecific(path).getFullpath()

Thanks

Note that you can also use Filename.toOsShortName() to do the same trick without win32api. But I’m not sure what encoding subprocess requires.

David