This is the mail archive of the
mailing list for the cygwin project.
Serious ;-): How does Windows pass non-ascii filename to executable?
- From: Shaddy Baddah <Shaddy_Baddah at hotmail dot com>
- To: cygwin-talk at cygwin dot com
- Date: Tue, 01 Nov 2005 12:33:32 +0800
- Subject: Serious ;-): How does Windows pass non-ascii filename to executable?
- Reply-to: The Cygwin-Talk Malingering List <cygwin-talk at cygwin dot com>
- Reply-to: Shaddy_Baddah at hotmail dot com, cygwin-talk at cygwin dot com
This question doesn't really describe a Cygwin topic (thus the use of
cygwin-talk), but it's probably as relevant for Cygwin as for regular
native Windows executables. Any assistance would be greatly appreciated.
Ok, what I want to know is, how does Windows pass non-ascii filenames to
executables? Here is the scenario. I have attached a quite simplistic C
I compile it under either MingW or Cygwin like so:
gcc -o nonasciifilenameargs nonasciifilenameargs.c
I then go to the Windows file explorer and drag a file with Traditional
Chinese characters in it, onto nonasciifilenameargs.exe.
I see this output:
argc == 2
argv == "d:\home\shaddy\throwaway scripts\nonasciifilenameargs.exe"
strlen(argv) == "57"
argv == "G:\?? - Susan?.mp3"
strlen(argv) == "18"
This is not a mystery to me. I get it that the encoding conversion to
the local codepage (which is latin1) drops question mark (?) characters
that are outside the codepage/set.
However, I can double click on the same file, and Winamp picks it up
(even if it doesn't handle the characters gracefully). So, there is
obviously a way to do it.
What is that way? I am vaguely familiar with a facility in Windows to
enter an executable at a different entry point then main()... as I
recall (eg. for XEmacs), to make the app non-console. Is this how it is
done? Any pointers to documentation would be greatly appreciated.
Thanks in advance,