Erich E. Hoover : chcp: Set the global codepage when called with an argument.

Alexandre Julliard julliard at winehq.org
Thu Dec 12 16:29:39 CST 2019


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

Author: Erich E. Hoover <erich.e.hoover at gmail.com>
Date:   Thu Nov  7 15:31:34 2019 -0700

chcp: Set the global codepage when called with an argument.

Signed-off-by: Erich E. Hoover <erich.e.hoover at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 programs/chcp.com/main.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/programs/chcp.com/main.c b/programs/chcp.com/main.c
index b943c227c9..6ace10cf93 100644
--- a/programs/chcp.com/main.c
+++ b/programs/chcp.com/main.c
@@ -19,6 +19,7 @@
 #include "wine/debug.h"
 
 #include "wincon.h"
+#include "stdlib.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(chcp);
 
@@ -31,8 +32,19 @@ int __cdecl wmain(int argc, WCHAR *argv[])
         printf("Active code page: %d\n", GetConsoleCP());
         return 0;
     }
+    else if (argc == 2)
+    {
+        int codepage = _wtoi(argv[1]);
+        int success = SetConsoleCP(codepage) && SetConsoleOutputCP(codepage);
+
+        if (!success)
+        {
+            printf("Invalid code page\n");
+        }
+        return !success;
+    }
 
-    WINE_FIXME("stub:");
+    WINE_FIXME("unexpected arguments:");
     for (i = 0; i < argc; i++)
         WINE_FIXME(" %s", wine_dbgstr_w(argv[i]));
     WINE_FIXME("\n");




More information about the wine-cvs mailing list