Skip to content

Instantly share code, notes, and snippets.

@shmup
Created December 8, 2025 21:35
Show Gist options
  • Select an option

  • Save shmup/3cb4ba9c2faf91895d28cbbae14b04c0 to your computer and use it in GitHub Desktop.

Select an option

Save shmup/3cb4ba9c2faf91895d28cbbae14b04c0 to your computer and use it in GitHub Desktop.
print out the cp437 glyph table
#!/usr/bin/env python
# print cp437 glyphs
# 0x00 ␀ 0x20 0x40 @ 0x60 ` 0x80 Ç 0xA0 á 0xC0 └ 0xE0 α
# 0x01 ☺ 0x21 ! 0x41 A 0x61 a 0x81 ü 0xA1 í 0xC1 ┴ 0xE1 ß
# 0x02 ☻ 0x22 " 0x42 B 0x62 b 0x82 é 0xA2 ó 0xC2 ┬ 0xE2 Γ
# 0x03 ♥ 0x23 # 0x43 C 0x63 c 0x83 â 0xA3 ú 0xC3 ├ 0xE3 π
# 0x04 ♦ 0x24 $ 0x44 D 0x64 d 0x84 ä 0xA4 ñ 0xC4 ─ 0xE4 Σ
# 0x05 ♣ 0x25 % 0x45 E 0x65 e 0x85 à 0xA5 Ñ 0xC5 ┼ 0xE5 σ
# 0x06 ♠ 0x26 & 0x46 F 0x66 f 0x86 å 0xA6 ª 0xC6 ╞ 0xE6 µ
# 0x07 • 0x27 ' 0x47 G 0x67 g 0x87 ç 0xA7 º 0xC7 ╟ 0xE7 τ
# 0x08 ◘ 0x28 ( 0x48 H 0x68 h 0x88 ê 0xA8 ¿ 0xC8 ╚ 0xE8 Φ
# 0x09 ○ 0x29 ) 0x49 I 0x69 i 0x89 ë 0xA9 ⌐ 0xC9 ╔ 0xE9 Θ
# 0x0A ◙ 0x2A * 0x4A J 0x6A j 0x8A è 0xAA ¬ 0xCA ╩ 0xEA Ω
# 0x0B ♂ 0x2B + 0x4B K 0x6B k 0x8B ï 0xAB ½ 0xCB ╦ 0xEB δ
# 0x0C ♀ 0x2C , 0x4C L 0x6C l 0x8C î 0xAC ¼ 0xCC ╠ 0xEC ∞
# 0x0D ♪ 0x2D - 0x4D M 0x6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╜ 0xDD ▌ 0xFD ²
# 0x1E ▲ 0x3E > 0x5E ^ 0x7E ~ 0x9E ₧ 0xBE ╛ 0xDE ▐ 0xFE ■
# 0x1F ▼ 0x3F ? 0x5F _ 0x7F ⌂ 0x9F ƒ 0xBF ┐ 0xDF ▀ 0xFF
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-l", "--labels", action="store_true", help="show labels for control codes")
args = parser.parse_args()
labels = {
0x00: "NULL",
0x07: "BELL",
0x09: "TAB",
0x0A: "LF",
0x0D: "CR",
0x1B: "ESC",
0x20: "SPC",
0x7F: "DEL",
}
control_glyphs = "␀☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼"
def glyph(i):
if i < 0x20:
return control_glyphs[i]
if i == 0x7F:
return "⌂"
return bytes([i]).decode("cp437")
def entry(i):
g = glyph(i)
if args.labels and i in labels:
return f"0x{i:02X} {g} ({labels[i]})"
return f"0x{i:02X} {g}"
entries = [entry(i) for i in range(256)]
col_width = max(len(e) for e in entries)
cols = 8 if not args.labels else 6
rows = 256 // cols + (1 if 256 % cols else 0)
for row in range(rows):
cells = []
for col in range(cols):
i = col * rows + row
if i < 256:
cells.append(entries[i].ljust(col_width))
print(" ".join(cells).rstrip())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment