Python argv and special characters

T

trapeze.jsg

Hi.

Platform: Win XP
Python version: 2.4.1
Running script from: cmd.exe (windows console)

I am having some trouble passing arguments to a python script having
special characters. In my case the argument is a filename (eg.
udtræk.xml). It seems like python tries to guess the encoding in which
the arguments are passed, instead of just recieving them in unicode,
thus using main() instead of wmain() inside the interpreter. So I get
an exception "IOError: [Errno 2] No such file or directory:
'udtr\xe6k.xml'" as a result.

How can I ensure a safe passing of arguments maybe having speciel
characters within.

Best Regards
Jakob Simon-Gaarde
 
N

Neil Hodgson

Jakob Simon-Gaarde:
How can I ensure a safe passing of arguments maybe having speciel
characters within.

Use ctypes to call the Windows GetCommandLine function. The
CommandLineToArgvW function can be used to break up the command line
string into arguments.

Neil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top