ASCII to PETSCII Converter
Convert ASCII text to PETSCII codes used by Commodore 64/128. View hex, decimal, binary output and pixel-perfect C64 character preview.
About
PETSCII (PET Standard Code of Information Interchange) is the character encoding system used by Commodore computers from 1977 onward, including the VIC-20, C64, and C128. It maps 256 code points across two modes: uppercase/graphics and lowercase/uppercase. Unlike standard ASCII where A occupies code point 65, PETSCII shifts printable letters and adds 64 unique block-graphic symbols with no direct ASCII equivalent. Confusing PETSCII screen codes with PETSCII keyboard codes is a common source of bugs in cross-development toolchains. This tool performs real mapping from 7-bit ASCII (0 - 127) into PETSCII code values, rendering each glyph through a pixel-accurate 8×8 bitmap font.
Incorrect encoding causes garbled output on real hardware and emulators. PRG files assembled with wrong mappings produce unreadable screens. This converter validates each input byte and flags unmappable characters rather than silently corrupting data. Note: control codes below 32 map to PETSCII control functions (cursor movement, color changes) and are shown as symbolic labels, not printable glyphs.
Formulas
PETSCII encoding applies a piecewise mapping function from ASCII code point a to PETSCII code point p. The primary transformation for printable letters in uppercase/graphics mode:
For the lowercase/uppercase mode, the mapping inverts: ASCII uppercase letters (65 - 90) map to PETSCII codes 193 - 218, and ASCII lowercase (97 - 122) maps to 65 - 90.
Where a = ASCII code point (decimal), p = resulting PETSCII code point (decimal), lookup = special-case table for symbols and control codes. Characters with no valid mapping produce a NULL result and are flagged in the output.
Reference Data
| ASCII Char | ASCII Dec | PETSCII Dec (Upper Mode) | PETSCII Hex | Notes |
|---|---|---|---|---|
| A | 65 | 65 | $41 | Maps to uppercase A in upper/graphics mode |
| a | 97 | 65 | $41 | Lowercase folds to uppercase in upper/gfx mode |
| Z | 90 | 90 | $5A | Direct mapping in upper range |
| 0 | 48 | 48 | $30 | Digits map identically |
| 9 | 57 | 57 | $39 | Digits map identically |
| Space | 32 | 32 | $20 | Identical mapping |
| ! | 33 | 33 | $21 | Punctuation preserved |
| @ | 64 | 0 | $00 | @ sign maps to PETSCII screen code 0 |
| [ | 91 | 27 | $1B | No direct equivalent; mapped to closest |
| \ | 92 | 191 | $BF | Backslash mapped to pound sign glyph area |
| ] | 93 | 29 | $1D | Mapped to closest bracket equivalent |
| ^ | 94 | 30 | $1E | Up-arrow in PETSCII |
| _ | 95 | 164 | $A4 | Underscore mapped to horizontal line |
| CR (Enter) | 13 | 13 | $0D | Carriage return - identical |
| LF | 10 | 13 | $0D | Line feed converted to CR |
| TAB | 9 | - | - | No PETSCII equivalent; flagged unmappable |
| DEL | 127 | 20 | $14 | Maps to PETSCII DELETE (INST/DEL) |
| ` | 96 | - | - | Backtick has no PETSCII mapping |
| ~ | 126 | 222 | $DE | Mapped to pi symbol area |
| { | 123 | - | - | No PETSCII equivalent; flagged |
| | | 124 | 221 | $DD | Mapped to vertical bar graphic |
| } | 125 | - | - | No PETSCII equivalent; flagged |