> Pathnames in Windows are in Unicode (UTF-16). Command line
> arguments are byte strings.

Actually, in NT-based Windows, all the internal stuff goes on in
UTF-16. The (multi-)byte string ("ANSI", i.e. system codepage) APIs
are just wrappers around the wide-char (UTF-16) string APIs. Also,
note that command line *arguments* (with which I assume you mean the C
argv things) are visible only by C (and C++) applications. The Windows
API manipulates only whole command lines (which is an idiotic design
decision, but I digress). It's the C and C++ startup code which splits
command lines into an Unixish argv.

If one uses the right compiler flags (if necessary) and makes a C or
C++ app have a wmain(int argc, wchar_t **argv) instead of the normal
main(int argc, char **argv), it will get command line arguments as
wide-char strings (as constructed from the wide-char command line by
the C runtime library startup code).

>  So, Explorer has to translate the UTF-16 pathname into a byte string.

Umm, no. As far as I know Explorer uses the wide-character API. So as
long as the application started uses the wide-character API to
retrieve its command line, it can retrieve it without loss even if it
contains characters not representable in the system codepage.

> Two things can go wrong: 1 The text encoding used by Explorer to
> translate the UTF-16 pathname into a byte string does not support
> all the characters in the pathname.

I don't think this can go wrong, if Explorer uses the wide-character
API. As far as I know, it does, as file names with random Unicode
characters work just fine in Explorer, and get passed to applications
like WordPad or MS Office just fine.

> 2 The text encoding guessed by OOo does not match the text encoding
> used by Explorer.

I doubt this is a question of guesswork, but the issue is that the
command line contains characters not representable in the system
codepage, and OOo fetches the command line using the "ANSI" API. I am
surprised, though, I am relatively sure I have seen that OOo does use
wide-char APIs in the low-level Win32 code. I haven't looked at the
OOo code involved in retrieving the command line lately, though.

--tml

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to