How do I echo ASCII art that contains special characters in a batch file?

前端 未结 6 2368
再見小時候
再見小時候 2021-02-12 11:45

So.. This is (to me anyway) the most important feature of this program. I need this to work. Please don\'t laugh.. (okay you can laugh) but when my program errors, I want it to

6条回答
  •  伪装坚强ぢ
    2021-02-12 11:48

    Include the following in your script:

    :::
    :::              _ _,---._
    :::           ,-','       `-.___
    :::          /-;'               `._
    :::         /\/          ._   _,'o \
    :::        ( /\       _,--'\,','"`. )
    :::         |\      ,'o     \'    //\
    :::         |      \        /   ,--'""`-.
    :::         :       \_    _/ ,-'         `-._
    :::          \        `--'  /                )
    :::           `.  \`._    ,'     ________,','
    :::             .--`     ,'  ,--` __\___,;'
    :::              \`.,-- ,' ,`_)--'  /`.,'
    :::               \( ;  | | )      (`-/
    :::                 `--'| |)       |-/
    :::                   | | |        | |
    :::                   | | |,.,-.   | |_
    :::                   | `./ /   )---`  )
    :::                  _|  /    ,',   ,-'
    :::                 ,'|_(    /-<._,' |--,
    :::                 |    `--'---.     \/ \
    :::                 |          / \    /\  \
    :::               ,-^---._     |  \  /  \  \
    :::            ,-'        \----'   \/    \--`.
    :::           /            \              \   \
    :::
    
    for /f "delims=: tokens=*" %%A in ('findstr /b ::: "%~f0"') do @echo(%%A
    

    The image could be placed anywhere within the script. It does not need to be near the FOR statement. I chose ::: as a distinguishing label for each image line because : is used for normal labels, and :: is frequently used as a comment.

    2014-10-22 Update

    There is an even simpler solution using my REPL.BAT utility - a hybrid JScript/batch script that performs a regex search/replace on stdin and writes the result to stdout. Simply substitute the following line for the FOR statement above:

    call repl "^:::" "" a <"%~f0"
    

    REPL.BAT is pure script that will run on any Windows machine from XP onward. Full documentation is embedded within the script. This solution uses the A option to only print lines that were altered.

提交回复
热议问题