icinfo: Fix vsnprintfW usage.
This commit is contained in:
parent
71377c5652
commit
b3b498b5cc
|
@ -29,33 +29,26 @@ static int mywprintf(const WCHAR *format, ...)
|
||||||
static WCHAR output_bufW[sizeof(output_bufA) / sizeof(WCHAR)];
|
static WCHAR output_bufW[sizeof(output_bufA) / sizeof(WCHAR)];
|
||||||
va_list parms;
|
va_list parms;
|
||||||
DWORD nOut;
|
DWORD nOut;
|
||||||
int len;
|
|
||||||
BOOL res = FALSE;
|
BOOL res = FALSE;
|
||||||
HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE);
|
HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
|
||||||
va_start(parms, format);
|
va_start(parms, format);
|
||||||
len = vsnprintfW(output_bufW, sizeof(output_bufW), format, parms);
|
vsnprintfW(output_bufW, sizeof(output_bufW), format, parms);
|
||||||
va_end(parms);
|
va_end(parms);
|
||||||
if (len < 0)
|
|
||||||
{
|
|
||||||
/* String too long */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Try to write as unicode whenever we think it's a console */
|
/* Try to write as unicode whenever we think it's a console */
|
||||||
if (((DWORD_PTR)hout & 3) == 3)
|
if (((DWORD_PTR)hout & 3) == 3)
|
||||||
{
|
{
|
||||||
res = WriteConsoleW(hout, output_bufW, len, &nOut, NULL);
|
res = WriteConsoleW(hout, output_bufW, strlenW(output_bufW), &nOut, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BOOL usedDefaultChar = FALSE;
|
|
||||||
DWORD convertedChars;
|
DWORD convertedChars;
|
||||||
|
|
||||||
/* Convert to OEM, then output */
|
/* Convert to OEM, then output */
|
||||||
convertedChars = WideCharToMultiByte(GetConsoleOutputCP(), 0, output_bufW, len,
|
convertedChars = WideCharToMultiByte(GetConsoleOutputCP(), 0, output_bufW, -1,
|
||||||
output_bufA, sizeof(output_bufA),
|
output_bufA, sizeof(output_bufA),
|
||||||
"?", &usedDefaultChar);
|
NULL, NULL);
|
||||||
res = WriteFile(hout, output_bufA, convertedChars, &nOut, FALSE);
|
res = WriteFile(hout, output_bufA, convertedChars, &nOut, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue