This is the mail archive of the cygwin-talk mailing list for the cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Serious ;-): How does Windows pass non-ascii filename to executable?


Hi,

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
test application.

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[0] == "d:\home\shaddy\throwaway scripts\nonasciifilenameargs.exe"
strlen(argv[0]) == "57"
argv[1] == "G:\?? - Susan?.mp3"
strlen(argv[1]) == "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,
Shaddy


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]