Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

cmd - Using box-drawing Unicode characters in batch files

I am making a batch file that uses these characters:

? ? ? ?

It is not working, it just terminates itself. I have seen people use characters like this:

?

It isnt the character but it turns into a character, can someone give me a list of these, shows the type of letter above and what it turns into?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you want to write console batch files that use those characters, you need an editor that will save the batch file using the console's code page. To check what that is, type:

C:>chcp
Active code page: 437

This is the result for my US Windows system. Western European versions of Windows will often be code page 850.

A good editor is Notepad++. Set that encoding in the editor (Encoding, Character sets, Western European, OEM-US) and copy the following characters into it:

@echo off
echo ╔═╦═╗ ┌─┬─┐ ╓─╥─╖ ╒═╤═╕
echo ║ ║ ║ │ │ │ ║ ║ ║ │ │ │
echo ╠═╬═╣ ├─┼─┤ ╟─╫─╢ ╞═╪═╡
echo ║ ║ ║ │ │ │ ║ ║ ║ │ │ │
echo ╚═╩═╝ └─┴─┘ ╙─╨─╜ ╘═╧═╛

Save the file as test.bat and run it from the console:

C:>test
╔═╦═╗ ┌─┬─┐ ╓─╥─╖ ╒═╤═╕
║ ║ ║ │ │ │ ║ ║ ║ │ │ │
╠═╬═╣ ├─┼─┤ ╟─╫─╢ ╞═╪═╡
║ ║ ║ │ │ │ ║ ║ ║ │ │ │
╚═╩═╝ └─┴─┘ ╙─╨─╜ ╘═╧═╛

When you open the file again in Notepad++, it is possible that you will see something like:

@echo off
echo éí?í? ú???? ??ò?· ?í?í?
echo o o o 3 3 3 o o o 3 3 3
echo ìí?í1 ????′ ??×?? ?í?íμ
echo o o o 3 3 3 o o o 3 3 3
echo èíêí? à?á?ù ó?D?? ?í?í?

Since there is no indication in the file what code page the characters in it represent, Notepad++ may choose the so-called ANSI code page. On US Windows that is Windows-1252. Just select the OEM-US encoding again to display it properly.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...