chcp.c

来自「PocketCMD是与pocketconsole配合实用的命令行解释器(Shel」· C语言 代码 · 共 81 行

C
81
字号
/* *  CHCP.C - chcp internal command. * * *  History: * *    23-Dec-1998 (Eric Kohl <ekohl@abo.rhein-zeitung.de>) *        Started. * */#include "config.h"#ifdef INCLUDE_CMD_CHCP#include "cmd.h"INT CommandChcp (LPTSTR cmd, LPTSTR param){	LPTSTR *arg;	INT    args;	UINT uOldCodePage;	UINT uNewCodePage;	/* print help */	if (!_tcsncmp (param, _T("/?"), 2))	{		ConOutPuts (_T("Displays or sets the active code page number.\n\n")			_T("CHCP [nnn]\n\n")			_T("  nnn   Specifies the active code page number.\n\n")			_T("Type CHCP without a parameter to display the active code page number."));		return 0;	}	/* get parameters */	arg = split (param, &args);	if (args == 0)	{		/* display active code page number */		ConOutPrintf (_T("Active code page: %u\n"), GetConsoleCP ());		return 0;	}	if (args >= 2)	{		/* too many parameters */		ConErrPrintf (_T("Invalid parameter format - %s\n"), param);		return 1;	}	/* save old code page */	uOldCodePage = GetConsoleCP ();	uNewCodePage = (UINT)_ttoi (arg[0]);	if (uNewCodePage == 0)	{		ConErrPrintf (_T("Parameter format incorrect - %s\n"), arg[0]);		freep (arg);		return 1;	}	if (!SetConsoleCP (uNewCodePage))	{		ConErrPrintf (_T("Invalid code page\n"));	}	else	{		SetConsoleOutputCP (uNewCodePage);		InitLocale ();	}	freep (arg);	return 0;}#endif /* INCLUDE_CMD_CHCP */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?