6831e576906bfc2783ccfe4e20a7e5d93fa59ccc
2 * CHCP.C - chcp internal command.
7 * 23-Dec-1998 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
12 #define WIN32_LEAN_AND_MEAN
16 #ifdef INCLUDE_CMD_CHCP
26 INT
CommandChcp (LPTSTR cmd
, LPTSTR param
)
32 if (!_tcsncmp (param
, _T("/?"), 2))
34 ConOutPuts (_T("Displays or sets the active code page number.\n\n"
36 " nnn Specifies the active code page number.\n\n"
37 "Type CHCP without a parameter to display the active code page number."));
42 arg
= split (param
, &args
);
46 /* display active code page number */
47 ConOutPrintf ("Active code page: %u\n", GetConsoleCP ());
51 /* too many parameters */
52 ConErrPrintf ("Invalid parameter format - %s\n", param
);
56 /* set active code page number */
61 /* save old code page */
62 uOldCodePage
= GetConsoleCP ();
64 uNewCodePage
= (UINT
)_ttoi (arg
[0]);
66 if (uNewCodePage
== 0)
68 ConErrPrintf ("Parameter format incorrect - %s\n", arg
[0]);
73 if (!SetConsoleCP (uNewCodePage
))
75 ConErrPrintf ("Invalid code page\n");
79 SetConsoleOutputCP (uNewCodePage
);
90 #endif /* INCLUDE_CMD_CHCP */