start:start.c Display messages in the console encoding.
Dmitry Timoshkov
dmitry at codeweavers.com
Tue Oct 23 20:53:28 CDT 2007
"Anatoly Lyutin" <vostok at etersoft.ru> wrote:
> static void output(const char *message)
> {
> - DWORD count;
> - WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), message, strlen(message), &count, NULL);
> + DWORD count = 0;
> + WCHAR *mesW = NULL;
> + char *mes = NULL;
> + int wlen = 0;
> + int len = 0;
There is no need to initialize variables to 0 since you are going
to explicitly initialize them later anyway.
> + wlen = MultiByteToWideChar( CP_ACP, 0, message, -1, NULL, 0 );
> + mesW = HeapAlloc( GetProcessHeap(), 0, wlen * sizeof(WCHAR) );
> + mes = HeapAlloc( GetProcessHeap(), 0, wlen * sizeof(char) );
Allocating wlen chars for 'mes' won't work correctly on a multibyte locale.
> + MultiByteToWideChar( CP_ACP, 0, message, -1, mesW, wlen );
> + len = WideCharToMultiByte( GetConsoleOutputCP(), 0, mesW, wlen, NULL, 0, NULL, NULL );
Just move the call to allocate 'len' bytes for 'mes' here.
> + WideCharToMultiByte( GetConsoleOutputCP(), 0, mesW, wlen, mes, len, NULL, NULL );
--
Dmitry.
More information about the wine-devel
mailing list