I’m trying to write a console application that can accept filename arguments and want it to be able to handle Unicode filenames. The problem is that I cannot figure out how to test it.
How can you pass Unicode arguments to a console app?
I tried creating a Unicode batch file that calls the program, passing it some Unicode characters, but it doesn’t work; the command-prompt can’t launch the program at all because it gets tripped up on the null-characters in its filename. I tried changing the code page to 65001 and Alt-typing a Unicode character at the command-line, but that didn’t work either.
Below is a sample program. I’m trying to find a way to get the following output:
C:\> unicodeargtest Foobar
46, 0, 6f, 0
// UnicodeArgTest.cpp
#define UNICODE
#include <tchar.h>
#include <stdio.h>
int wmain (int argc, wchar_t**argv) {
printf("%x, %x, %x, %x\n", argv[1][0], argv[1][1], argv[1][2], argv[1][3]);
}