Skip to content

Instantly share code, notes, and snippets.

@roblogic
Last active January 27, 2024 06:20
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roblogic/c36eee40b3800054432d707050532a67 to your computer and use it in GitHub Desktop.
Save roblogic/c36eee40b3800054432d707050532a67 to your computer and use it in GitHub Desktop.
Code Page 437 / Extended ASCII

CP437 is a ubiquitous character set that appears somewhat obsolete, but is still found everywhere. Usually seen in BIOS, there are no fancy fonts here. Here's the charset, using UTF-8 equivalents.

································ !"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~�
ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐
└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ 

Found this useful bash script on stackoverflow.

# heading index with div line
printf "\n      "; # indent

for x in {0..15}; do printf "%-3x" $x; done;
printf "\n%46s\n" | sed 's/ /-/g;s/^/      /';

# two lines with dots to represent control chars
c=$(echo "fa" | xxd -p -r | iconv -f 'CP437//' -t 'UTF-8')
printf "%32s" | sed 's/../'"$c"'  /g;s/^/  0   /;s/$/\n\n/'
printf "%32s" | sed 's/../'"$c"'  /g;s/^/  1   /'

# convert dec to codepage 437 in a table
for x in {32..255};
do

  # newline every 16 translated code values
  (( x % 16 == 0 )) && printf "\n\n"

  # left index numbers
  let "n = x % 15"
  (( (x % 16) == 0 )) && printf "%-4x" $n | sed 's/0/f/;s/^/  /'

  # conversion of x integer value to symbol
  printf "%02x" $x | xxd -p -r | iconv -f 'CP437//' -t 'UTF-8' | sed 's/.*/&  /'

  # div line
  (( x == 127 )) && printf "%46s" | sed 's/ /-/g;s/^/      /;i\ '

done
printf "%46s" | sed 's/ /-/g;s/^/\n      /;s/$/\n      /'; # div line
for x in {0..15}; do printf "%-3x" $x; done;
echo

Running it on TIO.run, yields this pretty table with all the characters rendered nicely (on my browser at least)

      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f        
      ----------------------------------------------
  0   ·  ·  ·  ·  ·  ·  ·  ·  ·  ·  ·  ·  ·  ·  ·  ·  

  1   ·  ·  ·  ·  ·  ·  ·  ·  ·  ·  ·  ·  ·  ·  ·  ·  

  2      !  "  #  $  %  &  '  (  )  *  +  ,  -  .  /  

  3   0  1  2  3  4  5  6  7  8  9  :  ;  <  =  >  ?  

  4   @  A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  

  5   P  Q  R  S  T  U  V  W  X  Y  Z  [  \  ]  ^  _  

  6   `  a  b  c  d  e  f  g  h  i  j  k  l  m  n  o  

  7   p  q  r  s  t  u  v  w  x  y  z  {  |  }  ~  �   
      ----------------------------------------------

  8   Ç  ü  é  â  ä  à  å  ç  ê  ë  è  ï  î  ì  Ä  Å  

  9   É  æ  Æ  ô  ö  ò  û  ù  ÿ  Ö  Ü  ¢  £  ¥  ₧  ƒ  

  a   á  í  ó  ú  ñ  Ñ  ª  º  ¿  ⌐  ¬  ½  ¼  ¡  «  »  

  b   ░  ▒  ▓  │  ┤  ╡  ╢  ╖  ╕  ╣  ║  ╗  ╝  ╜  ╛  ┐  

  c   └  ┴  ┬  ├  ─  ┼  ╞  ╟  ╚  ╔  ╩  ╦  ╠  ═  ╬  ╧  

  d   ╨  ╤  ╥  ╙  ╘  ╒  ╓  ╫  ╪  ┘  ┌  █  ▄  ▌  ▐  ▀  

  e   α  ß  Γ  π  Σ  σ  µ  τ  Φ  Θ  Ω  δ  ∞  φ  ε  ∩  

  f   ≡  ±  ≥  ≤  ⌠  ⌡  ÷  ≈  °  ∙  ·  √  ⁿ  ²  ■     
      ----------------------------------------------
      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment