时间:2021-05-22
One of my early posts on DosTips was a :chr routine that could convert a number into the corresponding character. The final code that appears near the end of the thread works really well, and is fast, but nearly all the characters must be embedded in the script. The TAB character in particular can be problematic, especially when trying to post the code on a forum site.
There is the undocumented %=ExitCodeAscii% dynamic variable that converts the most recent error code (from EXIT, not EXIT /B), but it is limited to codes between 32 and 126.
I had never seen a native method to generate a TAB character that works on all Windows versions - until now
I recently ran across this FORFILES documentation gem at SS64.COM:
复制代码 代码如下:
To include special characters in the command line, use the hex code for the character in 0xHH format (ex. 0x09 is theTAB character, 0x22 is the double quote " character.)
Eureeka :idea: - The following simple printHex routine can generate any byte code value except 0x00 (nul), 0x0A (newline), and 0x0D (carriage return). 8)
@echo offsetlocal::Define a Linefeed variableset LF=^::above 2 blank lines are critical - do not remove.::Create a TAB variablecall :hexprint "0x09" TAB::Print a string with encoded TABscall :hexprint "A0x09B0x09C"::Create a string variable with encoded TABscall :hexprint "A0x09B0x09C" varset varexit /b:hexPrint string [rtnVar] for /f eol^=^%LF%%LF%^ delims^= %%A in ( 'forfiles /p "%~dp0." /m "%~nx0" /c "cmd /c echo(%~1"' ) do if "%~2" neq "" (set %~2=%%A) else echo(%%Aexit /bI'll be playing Native American style flutes at a retreat in the Blue Ridge Mountains of Virginia for the next 4 days :D , without computer access :|
I wanted to post this before I left.
Enjoy the code, while I enjoy the crisp fall air. :)
Dave Benham
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
可以在批处理文件内的任何地方使用批处理参数,以提取有关环境设置的信息。Cmd.exe提供批处理参数扩展变量(%0到%9)。当在批处理文件中使用批处理参数时,%0
发个有用的东西——批处理创建快捷方式。非我原创,这里整理一下,希望对大家有用。一、批处理生成快捷方式:1、可以直接生成:echo[InternetShortcu
SQLSERVER编译与重编译编译的含义当SQLSERVER收到任何一个指令,包括查询(query)、批处理(batch)、存储过程、触发器(trigger)、
批处理判断是否为特殊字符用于判断输入的一个字符是否为"&^>中的符号。注意,匹配字符串中的空格不可省略!批处理代码:复制代码代码如下:@echooffsetIn
在批处理中,引号(")有时作为一个“特殊字符”的面貌出现,给批处理的编写还会造成一定的困扰,但是它在批处理代码编写的过程中又起到一些