diff --git a/programs/netstat/netstat.c b/programs/netstat/netstat.c index 16238ee097f..2c1ef89c231 100644 --- a/programs/netstat/netstat.c +++ b/programs/netstat/netstat.c @@ -125,7 +125,7 @@ static int WINAPIV NETSTAT_wprintf(const WCHAR *format, ...) } /* Convert to OEM, then output */ - convertedChars = WideCharToMultiByte(GetConsoleOutputCP(), 0, output_bufW, + convertedChars = WideCharToMultiByte(GetOEMCP(), 0, output_bufW, len, output_bufA, MAX_WRITECONSOLE_SIZE, "?", &usedDefaultChar); WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), output_bufA, convertedChars, diff --git a/programs/reg/reg.c b/programs/reg/reg.c index 16c05f958c7..4fd374579e9 100644 --- a/programs/reg/reg.c +++ b/programs/reg/reg.c @@ -51,22 +51,20 @@ const struct reg_type_rels type_rels[] = void output_writeconsole(const WCHAR *str, DWORD wlen) { - DWORD count, ret; + DWORD count; - ret = WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), str, wlen, &count, NULL); - if (!ret) + if (!WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), str, wlen, &count, NULL)) { DWORD len; char *msgA; /* On Windows WriteConsoleW() fails if the output is redirected. So fall - * back to WriteFile(), assuming the console encoding is still the right - * one in that case. + * back to WriteFile() with OEM code page. */ - len = WideCharToMultiByte(GetConsoleOutputCP(), 0, str, wlen, NULL, 0, NULL, NULL); + len = WideCharToMultiByte(GetOEMCP(), 0, str, wlen, NULL, 0, NULL, NULL); msgA = malloc(len); - WideCharToMultiByte(GetConsoleOutputCP(), 0, str, wlen, msgA, len, NULL, NULL); + WideCharToMultiByte(GetOEMCP(), 0, str, wlen, msgA, len, NULL, NULL); WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), msgA, len, &count, FALSE); free(msgA); }