IBM Code Page 437...

Hi all...

Reference this URL:
https://www.unix.com/unix-for-beginners-questions-and-answers/282400-lower-ascii-characters.html\#post303037272

Researching in google for an answer showed the numerous times this has been asked for in various guises.

So it inspired me to create a pseudo-IBM Code Page 437, the default ROM CGA-SVGA character set of yesteryear.
It really needs no step by step description as the code and images really speak for themselves.

This is now entirely owned by UNIX.COM...

#!/bin/bash
# GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu)
# Copyright © 2016 Free Software Foundation, Inc.
#
# Linux Mint 19, current update as of 28-07-2019.
#
# Author B.Walker, G0LCU - Issued as CC0 licence, (Public Domain), to UNIX.COM.
#
# CP437.sh
# Fun IBM Style Pseudo-CodePage 437 Demo...
#
# NOTE: The standard ASCII characters REMAIN STANDARD!

chr=( ' ' '☺' '☻' '♥' '♦' '♣' '♠' '-' '�-�' '�-�' '�-�' '♂' '♀' '♪' '♫' '☼' '�-�' '�-�' '↕' '��' '¶' '§' '�-�' '↨' '↑' '↓' '�'' '�' '∟' '↔' '�-�' '�-�' ' ' '!' '"' '#' '$' '%' '&' "'" '(' ')' '*' '+' ',' '-' '.' '/' '0' '1' '2' '3' '4' '5' '6' '7' '8' '9' ':' ';' '<' '=' '>' '?' '@' 'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L' 'M' 'N' 'O' 'P' 'Q' 'R' 'S' 'T' 'U' 'V' 'W' 'X' 'Y' 'Z' '[' '\' ']' '^' '_' '`' 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 'u' 'v' 'w' 'x' 'y' 'z' '{' '|' '}' '~' '⌂' 'Ç' 'ü' 'é' 'â' 'ä' 'à' 'å' 'ç' 'ê' 'ë' 'è' 'ï' 'î' 'ì' 'Ä' '�...' 'É' 'æ' 'Æ' 'ô' 'ö' 'ò' 'û' 'ù' 'ÿ' '�-' 'Ü' '¢' '£' '¥' '₧' '�'' 'á' 'í' 'ó' 'ú' 'ñ' 'Ñ' 'ª' 'º' '¿' '�' '¬' '½' '¼' '¡' '«' '»' '�-�' '�-'' '�-�' '│' '┤' '╡' '╢' '�-' '╕' '╣' '║' '�-' '�' '╜' '╛' '�' '└' '┴' '┬' '├' '─' '┼' '╞' '╟' '╚' '╔' '╩' '╦' '╠' '�' '╬' '╧' '╨' '╤' '╥' '╙' '╘' '�'' '╓' '╫' '╪' '┘' '┌' '�-�' '�-�' '�-�' '�-' '�-�' 'α' 'ß' 'Γ' 'π' 'Σ' 'σ' 'µ' 'τ' 'Φ' 'Θ' 'Ω' 'δ' '∞' 'φ' 'ε' '∩' '≡' '±' '≥' '≤' '⌠' '⌡' '÷' '≈' '°' '∙' '·' '√' '�' '²' '�-�' ' ' )

# This loop demonstrates array access.
for n in {0..255}
do
    # printf "Character ${n} = %s\n" "${chr[${n}]}"
    printf "%s" "${chr[${n}]}"
done > IBM_ASCII

# This section demonstrates 'bash' style string slicing from a variable.
echo ""
ext_ascii=$( cat IBM_ASCII )
echo "${ext_ascii}"
echo ""
echo "This is the full sized block character:- '"${ext_ascii:219:1}"'..."
echo "This is the NULL character, 0:- '"${ext_ascii:0:1}"', and is given a space character..."
echo "Similarly the BLANK character, 255:- '"${ext_ascii:255:1}"', and also given a space character..."
echo ""
4 Likes

Everyone appreciates these kinds of excellent and informative posts.

Thanks for this post for both the topic at hand (in the referenced link) and for future users who may run across a similar issue.

On behalf of our users, thank you wisecracker!

Your post in is the same spirit was what made the site great a decade ago.

Thank you again.

Neo

1 Like

Last upload by myself for this thread...
A fully POSIX compliant version using the default POSIX '#!/bin/sh' for Linux Mint 19, which is '#!/bin/dash'.

#!/bin/dash
# Default dash for......
# Linux Mint 19, current update as of 28-07-2019.
#
# Fully POSIX compliant Demo...
# Author B.Walker, G0LCU - Issued as CC0 licence, (Public Domain), to UNIX.COM.
#
# CP437_POSIX.sh
# Fun IBM Style Pseudo-CodePage 437 Demo...
#
# NOTE: The standard ASCII characters REMAIN STANDARD!

CP437=''
BLOCK=''
DITHER=''

# Create the _binary_ file...
printf "\040\342\230\272\342\230\273\342\231\245\342\231\246\342\231\243\342\231\240\342\200\242\342\227\230\342\227\213\342\227\231\342\231\202\342\231\200\342\231\252\342\231\253\342\230\274\342\226\272\342\227\204\342\206\225\342\200\274\302\266\302\247\342\226\254\342\206\250\342\206\221\342\206\223\342\206\222\342\206\220\342\210\237\342\206\224\342\226\262\342\226\274\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\342\214\202\303\207\303\274\303\251\303\242\303\244\303\240\303\245\303\247\303\252\303\253\303\250\303\257\303\256\303\254\303\204\303\205\303\211\303\246\303\206\303\264\303\266\303\262\303\273\303\271\303\277\303\226\303\234\302\242\302\243\302\245\342\202\247\306\222\303\241\303\255\303\263\303\272\303\261\303\221\302\252\302\272\302\277\342\214\220\302\254\302\275\302\274\302\241\302\253\302\273\342\226\221\342\226\222\342\226\223\342\224\202\342\224\244\342\225\241\342\225\242\342\225\226\342\225\225\342\225\243\342\225\221\342\225\227\342\225\235\342\225\234\342\225\233\342\224\220\342\224\224\342\224\264\342\224\254\342\224\234\342\224\200\342\224\274\342\225\236\342\225\237\342\225\232\342\225\224\342\225\251\342\225\246\342\225\240\342\225\220\342\225\254\342\225\247\342\225\250\342\225\244\342\225\245\342\225\231\342\225\230\342\225\222\342\225\223\342\225\253\342\225\252\342\224\230\342\224\214\342\226\210\342\226\204\342\226\214\342\226\220\342\226\200\316\261\303\237\316\223\317\200\316\243\317\203\302\265\317\204\316\246\316\230\316\251\316\264\342\210\236\317\206\316\265\342\210\251\342\211\241\302\261\342\211\245\342\211\244\342\214\240\342\214\241\303\267\342\211\210\302\260\342\210\231\302\267\342\210\232\342\201\277\302\262\342\226\240\040" > IBM_CP437

CP437=$( cat IBM_CP437 )

# Extract some characters and create a pseudo gradient...
echo ""
echo "${CP437}"
echo ""
echo "Obtain block character..."
BLOCK=${CP437%%�-�*}
BLOCK=${BLOCK##*┌}
echo "Now obtain 3 dithered characters..."
DITHER=${CP437%%│*}
DITHER=${DITHER##*»}
echo "Join a space, the DITHERs and BLOCK together to give a pseudo-gradient:-"
echo ""
echo "' ${DITHER}${BLOCK}'"
echo ""

Enjoy finding simple solutions to often difficult problems...
Bazza.