From 329a1c247a8eed2228b8e2911012426e52c4116f Mon Sep 17 00:00:00 2001 From: "Erich E. Hoover" Date: Thu, 7 Nov 2019 15:31:34 -0700 Subject: [PATCH] chcp: Set the global codepage when called with an argument. Signed-off-by: Erich E. Hoover Signed-off-by: Alexandre Julliard --- 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 b943c227c95..6ace10cf93e 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); - WINE_FIXME("stub:"); + if (!success) + { + printf("Invalid code page\n"); + } + return !success; + } + + WINE_FIXME("unexpected arguments:"); for (i = 0; i < argc; i++) WINE_FIXME(" %s", wine_dbgstr_w(argv[i])); WINE_FIXME("\n");