How to Use Extended ASCII Box-Drawing Characters in Batch Script
While professional UI designers use modern frameworks, Batch programmers have long relied on Extended ASCII Characters to create layouts. These characters, which include lines, corners, and blocks, allow you to build sophisticated "Text User Interfaces" (TUIs) that feature tables, window-like boxes, and progress bars directly in the command prompt.
In this guide, we will demonstrate how to access and use these characters to structure your script output.
The Essential Box-Drawing Charactersโ
Extended ASCII box-drawing characters are part of Code Page 65001, the original character set of the IBM PC. To use these characters in your Batch script, you must ensure your text editor saves the file in an encoding compatible with this code page, and your console is set to display it.
Single Line Charactersโ
| Character | Alt Code | Description |
|---|---|---|
| โ | Alt+218 | Top-Left Corner |
| โ | Alt+191 | Top-Right Corner |
| โ | Alt+192 | Bottom-Left Corner |
| โ | Alt+217 | Bottom-Right Corner |
| โ | Alt+196 | Horizontal Line |
| โ | Alt+179 | Vertical Line |
| โ | Alt+195 | Left T-Junction |
| โค | Alt+180 | Right T-Junction |
| โฌ | Alt+194 | Top T-Junction |
| โด | Alt+193 | Bottom T-Junction |
| โผ | Alt+197 | Cross Junction |
Double Line Characters (Professional Look)โ
| Character | Alt Code | Description |
|---|---|---|
| โ | Alt+201 | Top-Left Corner |
| โ | Alt+187 | Top-Right Corner |
| โ | Alt+200 | Bottom-Left Corner |
| โ | Alt+188 | Bottom-Right Corner |
| โ | Alt+205 | Horizontal Line |
| โ | Alt+186 | Vertical Line |
| โ | Alt+204 | Left T-Junction |
| โฃ | Alt+185 | Right T-Junction |
| โฆ | Alt+203 | Top T-Junction |
| โฉ | Alt+202 | Bottom T-Junction |
| โฌ | Alt+206 | Cross Junction |
Implementation Example: A "Popup" Boxโ
This script creates a centered alert box using double-line characters.
@echo off
chcp 65001 >nul
echo.
echo โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
echo โ โ
echo โ CRITICAL SYSTEM UPDATE โ
echo โ โ
echo โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
echo.
pause
Using "Blocks" for Visual Impactโ
Extended ASCII also includes "Block" characters that are perfect for headers, custom progress bars, or shaded backgrounds.
| Character | Alt Code | Description |
|---|---|---|
| โ | Alt+219 | Full Block |
| โ | Alt+178 | Dark Shade |
| โ | Alt+177 | Medium Shade |
| โ | Alt+176 | Light Shade |
Example: Header Barโ
@echo off
chcp 65001 >nul
echo โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
echo โ SYSTEM LOADING... โ
echo โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
echo.
pause
Example: Progress Barโ
@echo off
setlocal EnableDelayedExpansion
chcp 65001 >nul
set "progress=50"
set "barWidth=20"
:: Calculate filled and empty portions
set /a "filled=(progress * barWidth) / 100"
set /a "empty=barWidth - filled"
:: Build the bar
set "bar="
for /L %%i in (1,1,%filled%) do set "bar=!bar!โ"
for /L %%i in (1,1,%empty%) do set "bar=!bar!โ"
echo Progress: [!bar!] %progress%%%
pause
The "Code Page" Problemโ
If you save your script and run it, but see garbled symbols like รฦ or รขโข instead of box-drawing characters, your text editor is likely saving the file in UTF-8 encoding, but the console is set to Code Page 437 (the default for cmd.exe).
The Solution:โ
- Set the console code page: Add
chcp 437 >nulat the beginning of your script to ensure the console uses the correct character set. - Save the script file correctly:
- In Notepad (Windows 10+): Use File โ Save As, and select ANSI from the Encoding dropdown. This saves the file in the Windows-1252 code page, which is compatible with Code Page 437 for the box-drawing characters.
- In VS Code: Click the encoding indicator in the bottom-right status bar and select Save with Encoding โ Windows 1252. Alternatively, use UTF-8 with BOM, as the Byte Order Mark helps some terminals detect the encoding, but this is less reliable than ANSI/Windows-1252 for Batch scripts.
UTF-8 without BOM: Saving as UTF-8 without a BOM is the default in many modern editors, but this encoding is not compatible with cmd.exe for displaying extended ASCII characters. The box-drawing characters will appear as multi-byte UTF-8 sequences that cmd.exe interprets as multiple characters, producing garbled output.
Best Practicesโ
- Consistency: Don't mix single-line and double-line characters in the same box. It looks disorganized and unprofessional.
- Escaping: Unlike standard ASCII symbols (
|,<,>), these extended characters do not require carets (^) in a standardechocommand. They are not interpreted as special operators by Batch. - Spacing: Remember that a box-drawing character takes up exactly one character cell. If your content is 20 characters long, your top
โline must be exactly 20 characters (plus the corners) to align correctly. - Accessibility: Some older terminal emulators, remote SSH clients, or non-Windows systems might not display these characters correctly. If your script is for a global audience, consider a "Safe Mode" that uses standard
+,-, and|instead, or provide a command-line switch to toggle between extended ASCII and plain ASCII output.
Conclusionโ
Extended ASCII box-drawing characters provide the "Building Blocks" for meaningful UI design in a text-based environment. By mastering corners, lines, and blocks, you move beyond simple lines of text and begin creating structured, visual reports and tools that look and feel like established applications. Use them to frame your data, highlight your headers, and give your Batch tools a distinct and professional "Retro-Modern" identity.