Fix xcopy so output is either unicode (console) or oem (file)

Kirill K. Smirnov lich at math.spbu.ru
Mon Apr 23 05:08:20 CDT 2007


> 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dmitry_test_windows.JPG
Type: image/jpeg
Size: 52890 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20070423/afeb7f89/dmitry_test_windows-0001.jpe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dmitry_test_wine.jpg
Type: image/jpeg
Size: 66306 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20070423/afeb7f89/dmitry_test_wine-0001.jpg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: con_test_dmitry.c
Type: text/x-csrc
Size: 2307 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20070423/afeb7f89/con_test_dmitry-0001.c


More information about the wine-devel mailing list