2 * CHCP.C - chcp internal command.
7 * 23-Dec-1998 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
14 #ifdef INCLUDE_CMD_CHCP
24 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."));
43 /* display active code page number */
44 ConOutPrintf ("Active code page: %u\n", GetConsoleCP ());
50 /* too many parameters */
51 ConErrPrintf ("Invalid parameter format - %s\n", param
);
56 arg
= split (param
, &args
);
58 /* save old code page */
59 uOldCodePage
= GetConsoleCP ();
61 uNewCodePage
= (UINT
)_ttoi (arg
[0]);
63 if (uNewCodePage
== 0)
65 ConErrPrintf ("Parameter format incorrect - %s\n", arg
[0]);
70 if (!SetConsoleCP (uNewCodePage
))
72 ConErrPrintf ("Invalid code page\n");
76 SetConsoleOutputCP (uNewCodePage
);
85 #endif /* INCLUDE_CMD_CHCP */