Eric Pouech : netstat: Use OEM code page for output.

Alexandre Julliard julliard at winehq.org
Mon May 2 16:02:09 CDT 2022


Module: wine
Branch: master
Commit: b421477d339d7bfcd02a339d2f7de45870a307f7
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=b421477d339d7bfcd02a339d2f7de45870a307f7

Author: Eric Pouech <eric.pouech at gmail.com>
Date:   Thu Apr 28 11:22:40 2022 +0200

netstat: Use OEM code page for output.

Signed-off-by: Eric Pouech <eric.pouech at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 programs/netstat/netstat.c |  2 +-
 programs/reg/reg.c         | 12 +++++-------
 2 files changed, 6 insertions(+), 8 deletions(-)

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);
     }




More information about the wine-cvs mailing list