Re: Fix xcopy so output is either unicode (console) or oem (file)
wprintf does write unicode strings to a console, the problem in your test is that it doesn't change the locale from the default "C" to russian, and the conversion from unicode to code page simply fails.
I'm attaching a modified version of your test, with some results/conclusions: I failed to compile it under mingw32 nor winegcc as-is: con_test_dmitry.c:33:21: converting to execution character set: Invalid or incomplete multibyte or wide character con_test_dmitry.c:50:21: converting to execution character set: Invalid or incomplete multibyte or wide character
WriteConsole uses current console output code page to translate strings. wine - yes. windows - no. See attach.
WriteConsole does produce an output when not redirecting output to a file. Yes.
WriteConsole does not produce an output when redirecting output to a file, returns FALSE and sets last error to 6 (ERROR_INVALID_HANDLE). Yes.
wprintf translates unicode strings to current CRT multibyte locale before printing them either to a console or to a file.
printf doesn't care about locale at all, it simply prints what it has. I do not know much about msvcrt, but I can say, they suffer from the same bug as WriteConsole.
So, the patch sent by Jason is OK, except using wchar_t instead of WCHAR. Yes, it is OK. I understood that a bit later...
I've slightly modified your test to make it compile under mingw32. The results under windows and wine are attached. -- Kirill P.S. I've appiled Jason's patch during tests.
"Kirill K. Smirnov" <lich(a)math.spbu.ru> wrote:
WriteConsole uses current console output code page to translate strings. wine - yes. windows - no. See attach.
What makes you think so? Since I tested under Windows only I described the results I've got under it not under Wine. Wine behaviour is not interesting at this point. -- Dmitry.
participants (2)
-
Dmitry Timoshkov -
Kirill K. Smirnov