"Kirill K. Smirnov" lich@math.spbu.ru wrote:
Just little test:
#include <windows.h> #include <stdio.h>
int main(void) { WCHAR str_uni[]={0x044d, 0x0442, 0x043e, 0x0020, 0x0442, 0x0435, 0x0441, 0x0442, 0x0000}; char str_oem[]="~]â® àãá᪨© ⥪áâ in OEM";
wprintf(str_uni); printf(str_oem); return 0;
}
It will write both strings in wine and only second in windows. wprintf should not write unicode strings to console.
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:
WriteConsole uses current console output code page to translate strings.
WriteConsole does produce an output when not redirecting output to a file.
WriteConsole does not produce an output when redirecting output to a file, returns FALSE and sets last error to 6 (ERROR_INVALID_HANDLE).
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.
So, the patch sent by Jason is OK, except using wchar_t instead of WCHAR.