批處理生成幾乎任何字符,包括Tab
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 off setlocal ::Define a Linefeed variable set LF=^ ::above 2 blank lines are critical - do not remove. ::Create a TAB variable call :hexprint "0x09" TAB ::Print a string with encoded TABs call :hexprint "A0x09B0x09C" ::Create a string variable with encoded TABs call :hexprint "A0x09B0x09C" var set var exit /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(%%A exit /b
I'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
欄 目:DOS/BAT
下一篇:利用certutil.exe實現(xiàn)在批處理(bat)中嵌入exe文件的方法
本文標(biāo)題:批處理生成幾乎任何字符,包括Tab
本文地址:http://mengdiqiu.com.cn/a1/DOS_BAT/10061.html
您可能感興趣的文章
- 01-10使用批處理實現(xiàn)軟件的自動安裝以安裝搜狗拼音為例
- 01-10通過批處理修改DNS的代碼(推薦)
- 01-10windows使用批處理發(fā)布web到tomcat并啟動tomcat腳本分享
- 01-10再談DOS批處理下格式化日期字符串的三種方法(詳解)
- 01-10用批處理一鍵安裝兩種擴(kuò)展名的Windows系統(tǒng)補(bǔ)丁
- 01-10ip地址切換批處理腳本分享
- 01-10批處理楊輝三角效果實現(xiàn)代碼
- 01-10將批處理文件注冊成服務(wù)在系統(tǒng)啟動的時候自動調(diào)用
- 01-10批處理輸出n階幻方腳本
- 01-10dos批處理文件中的變量小結(jié)


閱讀排行
本欄相關(guān)
- 01-10DOS下查看硬盤分區(qū)該使用什么命令
- 01-10使用批處理實現(xiàn)軟件的自動安裝以安
- 01-10后臺運(yùn)行bat定時器程序示例分享
- 01-10通過批處理修改DNS的代碼(推薦)
- 01-10dota2服務(wù)器ping測試腳本分享
- 01-10再談DOS批處理下格式化日期字符串的
- 01-10windows使用批處理發(fā)布web到tomcat并啟動
- 01-10win7怎么設(shè)定關(guān)閉顯示器時間
- 01-10屏蔽up鍵禁止游戲運(yùn)行腳本分享
- 01-10win7創(chuàng)建wifi熱點(diǎn)腳本分享
隨機(jī)閱讀
- 01-10C#中split用法實例總結(jié)
- 08-05dedecms(織夢)副欄目數(shù)量限制代碼修改
- 08-05DEDE織夢data目錄下的sessions文件夾有什
- 01-10SublimeText編譯C開發(fā)環(huán)境設(shè)置
- 01-10使用C語言求解撲克牌的順子及n個骰子
- 01-10delphi制作wav文件的方法
- 08-05織夢dedecms什么時候用欄目交叉功能?
- 01-11ajax實現(xiàn)頁面的局部加載
- 01-11Mac OSX 打開原生自帶讀寫NTFS功能(圖文
- 04-02jquery與jsp,用jquery