Skip to content

How to Use Extended ASCII Box-Drawing Characters in Batch Script

Learn how to create professional text-based UIs in Batch scripts using Extended ASCII box-drawing characters, including single/double lines, corners, and blocks, with encoding and implementation best practices.

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:

  1. Set the console code page: Add chcp 437 >nul at the beginning of your script to ensure the console uses the correct character set.
  2. 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.

Best Practices

  1. Consistency: Don't mix single-line and double-line characters in the same box. It looks disorganized and unprofessional.
  2. Escaping: Unlike standard ASCII symbols (|, <, >), these extended characters do not require carets (^) in a standard echo command. They are not interpreted as special operators by Batch.
  3. 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.
  4. 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.

Navigation