Unicode to DOS filenames (to call FSUM.exe)

John Machin sjmachin at lexicon.net
Mon May 15 13:15:44 CEST 2006

According to my reading of the source, the function you have called
expects an 8-bit string.
static PyObject *
PyGetShortPathName(PyObject * self, PyObject * args)
	char *path;
	if (!PyArg_ParseTuple(args, "s:GetShortPathName", &path))
If it is given Unicode, PyArg_ParseTuple will attempt to encode it
using the default encoding (ascii). Splat.

Looks like you need a GetShortPathNameW() but it's not implemented.
Raise it as an issue on the pywin32 sourceforge bug register. Tell Mark
I sent you :-)

It may be possible to fake up your default encoding to say cp1252 BUT
take the advice of anyone who screams "Don't do that!" and in any case
this wouldn't help you with a Russian, Chinese, etc etc filename.

Another thought: try using ctypes.

Hope some of this helps,

More information about the Python-list mailing list