2 * CHCP.C - chcp internal command.
7 * 23-Dec-1998 (Eric Kohl)
10 * 02-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
11 * Remove all hardcode string to En.rc
18 #ifdef INCLUDE_CMD_CHCP
20 INT
CommandChcp (LPTSTR cmd
, LPTSTR param
)
22 TCHAR szMsg
[RC_STRING_MAX_SIZE
];
28 if (!_tcsncmp (param
, _T("/?"), 2))
30 ConOutResPaging(TRUE
,STRING_CHCP_HELP
);
37 arg
= split (param
, &args
, FALSE
);
41 /* display active code page number */
42 LoadString(CMD_ModuleHandle
, STRING_CHCP_ERROR1
, szMsg
, RC_STRING_MAX_SIZE
);
43 ConErrPrintf(szMsg
, InputCodePage
);
49 /* too many parameters */
50 LoadString(CMD_ModuleHandle
, STRING_ERROR_INVALID_PARAM_FORMAT
, szMsg
, RC_STRING_MAX_SIZE
);
51 ConErrPrintf(szMsg
, param
);
56 uNewCodePage
= (UINT
)_ttoi(arg
[0]);
58 if (uNewCodePage
== 0)
60 LoadString(CMD_ModuleHandle
, STRING_ERROR_INVALID_PARAM_FORMAT
, szMsg
, RC_STRING_MAX_SIZE
);
61 ConErrPrintf(szMsg
, arg
[0]);
67 if (!SetConsoleCP(uNewCodePage
))
69 ConErrResPuts(STRING_CHCP_ERROR4
);
74 SetConsoleOutputCP (uNewCodePage
);
76 InputCodePage
= GetConsoleCP();
84 #endif /* INCLUDE_CMD_CHCP */