批次處理特殊字符

批次處理特殊字符

我使用的是 Windows 7,我想用這樣的特殊字元建立選單、進度條等。這個怎麼做?

在此輸入影像描述

答案1

重點是 - 你需要使用 UTF-8 格式,看一看:

步驟1]以「UTF 8」格式建立一個新的CMD腳本。 (PsPad 或 Notepad++ 編輯器可以做到這一點)

步驟2]在第一行留一空行。 UTF 8 標頭存放在那裡。

步驟3]複製貼上以下程式碼:

@echo off
CHCP 65001
:: *****************************************************************************
:: * Author: Gustaaf von Pickartz.                                             *
:: * Date Created: 22nd July, 2012.                                            *
:: * ------------------------------------------------------------------------- *
:: * This program is provided as is and for fair use distribution.             *
:: * Give credit where credit is due to the author in your own script.         *
:: * ------------------------------------------------------------------------- *
:: *****************************************************************************
SETLOCAL ENABLEDELAYEDEXPANSION

:: Progress Bar
 SET PRG0=[░░░░░░░░░░]
 SET PRG1=[▓░░░░░░░░░]
 SET PRG2=[▓▓░░░░░░░░]
 SET PRG3=[▓▓▓░░░░░░░]
 SET PRG4=[▓▓▓▓░░░░░░]
 SET PRG5=[▓▓▓▓▓░░░░░]
 SET PRG6=[▓▓▓▓▓▓░░░░]
 SET PRG7=[▓▓▓▓▓▓▓░░░]
 SET PRG8=[▓▓▓▓▓▓▓▓░░]
 SET PRG9=[▓▓▓▓▓▓▓▓▓░]
SET PRG10=[▓▓▓▓▓▓▓▓▓▓]

:: Star
 SET STR1=/
 SET STR2=--
 SET STR3=\
 SET STR4=^|

:: Please note there are special ASCII insertions in the SET BKSPC= declaration below. 80x backspace characters are inserted. ASCII Value 08=[BS]
:: Be sure to verify they are still there when you cut and paste from the web with your text editor (Notepad++ or PsPad). Insert them if missing, otherwise this script will not work...
SET BKSPC=


:Begin_Main
echo.
echo.
Echo Simple Animated star.
FOR /L %%I IN (1,1,400) DO (
<NUL (SET/P Z= PROGRESS: │)
<NUL (SET/P Z=%BKSPC%)
<NUL (SET/P Z= PROGRESS: /)
<NUL (SET/P Z=%BKSPC%)
<NUL (SET/P Z= PROGRESS: ─)
<NUL (SET/P Z=%BKSPC%)
<NUL (SET/P Z= PROGRESS: \)
<NUL (SET/P Z=%BKSPC%)
)

echo.
echo.
Echo Simple Progress bar indicator
FOR /L %%I IN (0,1,10) DO (
IF %%I LEQ 9 (SET TIC=0%%I) ELSE (SET TIC=%%I)
<NUL (SET/P Z=[!TIC!/10] PROGRESS: !PRG%%I!)
>NUL PING -n 2 localhost
<NUL (SET/P Z=%BKSPC%)
)

echo.
echo.
Echo Combined Progress bar and animated star...
FOR /L %%I IN (0,1,10) DO (
IF %%I LEQ 9 (SET TIC=0%%I) ELSE (SET TIC=%%I)
<NUL (SET/P Z=[!TIC!/10] PROGRESS: !PRG%%I!)
<NUL (SET/P Z=%BKSPC%)
    FOR /L %%J IN (1,1,400) DO (
    <NUL (SET/P Z=[!TIC!/10] PROGRESS: !PRG%%I! │)
    <NUL (SET/P Z=%BKSPC%)
    <NUL (SET/P Z=[!TIC!/10] PROGRESS: !PRG%%I! /)
    <NUL (SET/P Z=%BKSPC%)
    <NUL (SET/P Z=[!TIC!/10] PROGRESS: !PRG%%I! ─)
    <NUL (SET/P Z=%BKSPC%)
    <NUL (SET/P Z=[!TIC!/10] PROGRESS: !PRG%%I! \)
    <NUL (SET/P Z=%BKSPC%)
    )
<NUL (SET/P Z=%BKSPC%)
)

步驟 4] 確保在 SET BKSPC= (http://columbia.edu/kermit/ascii.html

步驟 5] 確保將 CMD 控制台字體設定為 True Type 字體,而不是光柵字體。

相關內容