[start][start] Output with console encoding

Vitaliy Margolen wine-devel at kievinfo.com
Sun Feb 18 10:18:33 CST 2007


> Changelog:
> Fix output console to output with console encoding.
>  static void output(const char *message)
> Index: programs/start/start.c
> ===================================================================
> RCS file: /home/wine/wine/programs/start/start.c,v
> retrieving revision 1.5
> diff -u -p -u -r1.5 start.c
> --- programs/start/start.c	23 May 2006 12:49:22 -0000	1.5
> +++ programs/start/start.c	30 Jan 2007 09:47:52 -0000
> @@ -33,7 +33,20 @@
>  {
>  	DWORD count;
> -	WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), message, strlen(message), &count, NULL);
> +       WCHAR *bufW;
> +       char  *bufC;
> +       int   len = strlen(message);
> +       bufW = calloc(len+1,sizeof(WCHAR));
> +       bufC = calloc(len+1,sizeof(CHAR));
> +
> +       MultiByteToWideChar( CP_ACP, 0, message, len, bufW, len );
> +       WideCharToMultiByte( GetConsoleOutputCP(), 0, bufW, len, bufC, len, NULL, NULL );
> +       bufC[len] = '\0';
> +    
> +       WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), bufC, len, &count, NULL);
> +
> +       free(bufW);
> +       free(bufC);
>  }


This is not correct. This function and everything else, using it should
be rewritten as unicode, not ansi. Also you should use HeapAlloc/HeapFree.

Vitaliy.



More information about the wine-devel mailing list