A Go program that converts text strings into ASCII art using predefined banner templates.
ASCII-ART receives a string as an argument and outputs a graphical representation of the text using ASCII characters. Each character is rendered as an 8-line tall ASCII art representation based on banner template files.
Team Project
ASCII-ART/
├── banners/
│ ├── standard.txt
│ ├── shadow.txt
│ └── thinkertoy.txt
├── MethodsAndTesting/
│ ├── file-handling.go
│ ├── printer.go
│ └── printer_test.go
├── main.go
├── go.mod
└── README.md
- Converts text to ASCII art using banner templates
- Supports all printable ASCII characters (32-126)
- Handles newline characters (
\n) - Multiple banner styles available (standard, shadow, thinkertoy)
- Comprehensive unit tests
- Clean modular code structure
- Clone the repository:
git clone <repository-url>
cd ASCII-ART- Ensure you have Go installed (version 1.16 or higher):
go version- Initialize the module (if not already done):
go mod init ascii-artgo run . "Your text here"Simple text:
go run . "hello"Output:
_ _ _
| | | | | |
| |__ ___ | | | | ___
| _ \ / _ \ | | | | / _ \
| | | | | __/ | | | | | (_) |
|_| |_| \___| |_| |_| \___/
Uppercase text:
go run . "HELLO"With newlines:
go run . "Hello\nWorld"Output:
_ _ _ _
| | | | | | | |
| |__| | ___ | | | | ___
| __ | / _ \ | | | | / _ \
| | | | | __/ | | | | | (_) |
|_| |_| \___| |_| |_| \___/
__ __ _ _
\ \ / / | | | |
\ \ /\ / / ___ _ __ | | __| |
\ \/ \/ / / _ \ | '__| | | / _` |
\ /\ / | (_) | | | | | | (_| |
\/ \/ \___/ |_| |_| \__,_|
Special characters:
go run . "[\]^_ 'a"Numbers and symbols:
go run . "Hello123!"The program supports all printable ASCII characters from space (32) to tilde (126):
- Lowercase letters:
a-z - Uppercase letters:
A-Z - Numbers:
0-9 - Special characters:
!@#$%^&*()_+-=[]{}|;:'",.<>?/~and space
Each banner file contains ASCII representations of characters where:
- Each character is exactly 8 lines tall
- Characters are separated by a newline (9 lines total per character)
- Characters are ordered by ASCII value (32-126)
- Banner files are stored in the
banners/directory
Entry point of the application. Handles command-line arguments and calls the formatter.
Contains FileHandler() function that reads the banner template file.
Key Function:
func FileHandler() ([]byte, bool)- Reads
banners/standard.txt - Returns file contents and success status
- Handles file reading errors
Contains FormatPrinter() function that processes the input string and generates ASCII art.
Key Function:
func FormatPrinter(input string) string- Splits input by
\nto handle multiple lines - Maps each character to its ASCII art representation
- Builds output line by line (8 rows per text line)
- Returns formatted ASCII art string
Algorithm:
- Load banner file using
FileHandler() - Split banner content into lines
- Split input string by
\n - For each word/line:
- If empty, add a newline
- For each of 8 rows:
- For each character, find its representation in banner
- Calculate line index:
(ASCII_value - 32) * 9 + 1 + row - Append character's row to output
- Trim final newline
Unit tests for the FormatPrinter() function.
Test Cases:
- Simple text (
"hello") - Special characters (
"[\]^_ 'a") - Newline handling (
"hello\n") - Multiple newlines (
"hello\n\n")
Execute all tests:
go test ./MethodsAndTestingRun tests with verbose output:
go test -v ./MethodsAndTestingRun specific test:
go test -run TestFormatPrinter ./MethodsAndTestingThe program handles the following errors:
- Incorrect number of arguments:
error: enter 2 arguments
- Banner file not found:
Error
(Program terminates with fatal error)
-
Empty input: Program returns without output
-
Invalid characters: Characters outside ASCII 32-126 are silently skipped
Each ASCII character (32-126) occupies 9 lines in the banner file:
- Lines 1-8: ASCII art representation
- Line 9: Empty separator
Formula:
lineIndex = (charASCII - 32) * 9 + 1 + rowNumber
Where:
charASCII: ASCII value of characterrowNumber: Current row (0-7)32: ASCII value of space (first printable character)
Input string "Hello\nWorld" is split into:
["Hello", "World"]
Each segment is processed separately with 8-line output.
Empty segments (from "\n\n") produce single newline in output.
- Language: Go (Golang)
- Go Version: 1.16 or higher
- Packages: Standard library only
os: File operations and command-line argumentsfmt: Formatted I/Ostrings: String manipulationlog: Error loggingtesting: Unit tests
✅ Modular code - Functions separated by responsibility
✅ Unit tests - Comprehensive test coverage
✅ Error handling - Proper error checking and reporting
✅ Clean code - Readable and maintainable
✅ No external dependencies - Uses only standard library
This project helps you learn about:
- Go file system (fs) API
- Data manipulation in Go
- String processing
- ASCII character encoding
- Command-line argument handling
- Unit testing in Go
- Code organization and modularity
Potential improvements:
- Support for multiple banner styles (shadow, thinkertoy)
- Custom banner file selection via command-line flag
- Color output support
- Export to file option
- UTF-8 character support
- Interactive mode
This project is part of an educational program.
Problem: Error message when running
- Solution: Ensure
banners/standard.txtexists in the correct location
Problem: Wrong output format
- Solution: Verify banner file format (8 lines per character + 1 separator)
Problem: Tests failing
- Solution: Run from project root directory where
banners/folder is accessible
Problem: Characters not displaying
- Solution: Check if character is in printable ASCII range (32-126)
For questions or issues, please contact the development team.
Note: This is an educational project demonstrating ASCII art generation and Go programming concepts.