Fixed Unicode string output.

This commit is contained in:
Catalin Patulea 2003-06-30 20:19:42 +00:00 committed by Alexandre Julliard
parent 12acfb2285
commit 2e7c0de616
1 changed files with 38 additions and 6 deletions

View File

@ -32,6 +32,7 @@
#include "winuser.h" #include "winuser.h"
#include "excpt.h" #include "excpt.h"
#include "wine/library.h" #include "wine/library.h"
#include "winnls.h"
DBG_PROCESS* DEBUG_CurrProcess = NULL; DBG_PROCESS* DEBUG_CurrProcess = NULL;
DBG_THREAD* DEBUG_CurrThread = NULL; DBG_THREAD* DEBUG_CurrThread = NULL;
@ -58,12 +59,43 @@ void DEBUG_OutputA(int chn, const char* buffer, int len)
void DEBUG_OutputW(int chn, const WCHAR* buffer, int len) void DEBUG_OutputW(int chn, const WCHAR* buffer, int len)
{ {
/* FIXME: this won't work is std output isn't attached to a console */ char* ansi = NULL;
if (DBG_IVAR(ConChannelMask) & chn) int newlen;
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), buffer, len, NULL, NULL);
/* simplistic Unicode to ANSI conversion */ /* do a serious Unicode to ANSI conversion
if (DBG_IVAR(StdChannelMask) & chn) FIXME: should CP_ACP be GetConsoleCP()? */
while (len--) fputc((char)*buffer++, stderr); newlen = WideCharToMultiByte(CP_ACP, 0, buffer, len, NULL, 0, NULL, NULL);
if(newlen)
{
ansi = (char*)DBG_alloc(newlen);
if(ansi)
{
WideCharToMultiByte(CP_ACP, 0, buffer, len, ansi, newlen, NULL, NULL);
}
}
/* fall back to a simple Unicode to ANSI conversion in case WC2MB failed */
if(!ansi)
{
ansi = DBG_alloc(len);
if(ansi)
{
int i;
for(i = 0; i < len; i++)
{
ansi[i] = (char)buffer[i];
}
newlen = len;
}
/* else we are having REALLY bad luck today */
}
if(ansi)
{
DEBUG_OutputA(chn, ansi, newlen);
DBG_free(ansi);
}
} }
int DEBUG_Printf(int chn, const char* format, ...) int DEBUG_Printf(int chn, const char* format, ...)