Eric Pouech : chcp: 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: ebd24cbbc04d523dbd62232d3971339208a87dc7
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=ebd24cbbc04d523dbd62232d3971339208a87dc7

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

chcp: 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/chcp.com/main.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/programs/chcp.com/main.c b/programs/chcp.com/main.c
index 6c5864d0e19..b4309ff086d 100644
--- a/programs/chcp.com/main.c
+++ b/programs/chcp.com/main.c
@@ -26,10 +26,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(chcp);
 
 static 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;
@@ -38,10 +37,11 @@ static void output_writeconsole(const WCHAR *str, DWORD wlen)
          * back to WriteFile(), assuming the console encoding is still the right
          * one in that case.
          */
-        len = WideCharToMultiByte(GetConsoleOutputCP(), 0, str, wlen, NULL, 0, NULL, NULL);
+        len = WideCharToMultiByte(GetOEMCP(), 0, str, wlen, NULL, 0, NULL, NULL);
         msgA = malloc(len);
+        if (!msgA) return;
 
-        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