PETSCII
| Company type | Character encoding system |
|---|---|
| Industry | Computing / Computer hardware |
| Founded | 1977 |
| Founder | Leonard Tramiel, Chuck Peddle |
| Products | Character set for Commodore 8-bit home computers |
PETSCII (short for PET Standard Code of Information Interchange), also referred to as CBM ASCII, represents the character encoding system utilized by Commodore Business Machines' series of 8-bit home computers.
Initially launched with the Commodore PET in 1977, PETSCII was subsequently adopted across several models including the CBM-II, VIC-20, Commodore 64, Commodore 16, Commodore 116, Plus/4, and Commodore 128. In contrast, the Amiga computers employed the ISO/IEC 8859-1 standard instead.
History
The primary architects behind PETSCII were Leonard Tramiel, son of Commodore's CEO Jack Tramiel, and Chuck Peddle, who also contributed to the design of the PET. The graphical symbols formed part of Commodore’s enhancements to Microsoft’s MOS Technology 6502 BASIC introduced in 1977. While the VIC-20 utilized an identical pixel-perfect font as the PET, its characters appeared broader due to a 22-column screen layout. The Commodore 64 featured a slightly modified uppercase font with bolder strokes to avoid color distortion on its higher-resolution display; its lowercase set was similar to that found on earlier Atari 8-bit systems.
Chuck Peddle explained that card suit symbols were incorporated specifically to facilitate straightforward development of card games on the PET platform.
Specifications
The "unshifted" PETSCII character set is derived from the 1963 ASCII standard and includes only uppercase alphabetic characters. Notably, it replaces the caret symbol (^) at code 0x5E with an up-arrow (↑), and substitutes the underscore (_) at code 0x5F with a left-arrow (←). Except for the original Commodore PET model, a British pound sign (£) appears at code 0x5C instead of a backslash (\). Characters introduced in the ASCII revision of 1967—such as lowercase letters, grave accents, curly braces, vertical bars, and tildes—are not present. The range from 0xA0 to 0xDF contains Commodore-specific semigraphic blocks including lines, hatch patterns, shading variants, geometric shapes like triangles and circles, as well as card suit icons.
PETSCII also provides a "shifted" or "business mode," which swaps uppercase letters (codes 0x41–0x5A) for their lowercase equivalents and transforms graphic characters (codes 0xC1–0xDA) into uppercase letters. This mode can be activated by holding SHIFT while pressing the Commodore key or through POKE commands targeting memory locations such as 59468 with values like 14 or 12. On the Commodore 64, bit 2 in memory address 53272 governs this shift state. Certain PET models utilize control code PRINT CHR$(14) to toggle this mode; however, this method also modifies line spacing. Using POKE commands enables toggling without affecting spacing.
Included within PETSCII are control codes for cursor positioning and screen management such as {HOME}, {CLR}, {RVS ON}, and {RVS OFF}, which enable reverse-video effects. In program listings, these controls are often displayed as reverse-video symbols; some printed materials replace them with descriptive names enclosed in curly braces for clarity since PETSCII does not contain curly brace characters itself.
There are two distinct character mappings: an "interchange" set used by CHR$() for storing data and a "video" set for rendering on screen. For example, when displaying the string "@ABC" directly into screen memory, one must POKE decimal values 0 through 3 instead of using ASCII codes ranging from 64 to 67.
By default, the keyboard inputs characters from the lower half of the code page; engaging Shift accesses characters from the upper half. Some PETSCII codes are non-printable and serve special input functions such as F1 or RUN/STOP keys.
Character set
The following tables illustrate the "interchange" PETSCII character set utilized by the CHR$() function.
Control codes are found in the 0x00–0x1F and 0x80–0x9F intervals; however, their interpretations differ depending on the hardware platform. These control characters are omitted here and are instead described in detail under § Control characters.
The code ranges 0x60–0x7F and 0xE0–0xFF represent duplicated sets that vary according to the system. Specifically, on the Commodore PET, these ranges replicate 0x20–0x3F and 0xA0–0xBF, whereas on VIC-20, C64, C16, and C128 models, they duplicate 0xC0–0xDF and 0xA0–0xBF. Although these duplicates appear identical visually, they fulfill distinct roles; for instance, on the PET, both 0x2C and 0x6C render a comma symbol, but only 0x2C functions as an input delimiter.
Most graphic symbols maintain consistency across different systems except for a few exceptions: code 0x5C represents a backslash on the PET but a pound sign elsewhere; code 0xDE corresponds to an alternate CHECKER BOARD FILL; and the duplicated range 0x60–0x7F on the PET differs as well. Moreover, the shifted character set of the Commodore PET 2001 model reverses uppercase and lowercase letters relative to other machines.
Unicode mappings
PETSCII characters correspond to multiple Unicode blocks including:
- Basic Latin (U+0000–U+007F)
- Latin-1 Supplement (U+0080–U+00FF)
- Greek and Coptic (e.g., U+03C0)
- General Punctuation (e.g., U+2022)
- Arrows (U+2190, U+2191)
- Box Drawing (U+2500–U+257F)
- Block Elements (U+2580–U+259F)
- Geometric Shapes (U+25A0–U+25FF)
- Miscellaneous Symbols (U+2600–U+26FF)
- Dingbats (e.g., U+2713)
- Symbols for Legacy Computing (U+1FB00–U+1FBFF; introduced in Unicode version 13.0, released in 2020)
Standard encoding
Presented below is the PETSCII character set employed by Commodore's VIC-20, C64, C16, and C128 computers.
Unshifted
| Hex | Character | Unicode | Description |
|---|
| Hex | Character | Unicode | Description |
|---|
| Hex | Character | Unicode | Description |
|---|
Shifted
Unshifted
|}
|- |- |- |- |- |- |- |- |- |- |- |- |- |- |- |- |- |- |}
|- |- |- |- |- |- |- |- |- |- |- |- |- |- |- |- | {-} | {-}
Return the rewritten MediaWiki chunk only.
Shifted
| Template:Chset-left1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 |
| Template:Chset-left1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 | Template:Chset-cell1 |
| Template:Chset-left1 | !|"|#|$|%|&|'|( |)|*|+|,|-|.|/ | |||||||||||||||
| Template:Chset-left1 | 1|2|3|4|5|6|7|8|9|:|;|<|=|>|? | |||||||||||||||
| Template:Chset-left1 | a |b |c |d |e |f |g |h |i |j |k |l |m |n |o | |||||||||||||||
| Template:Chset-left1 | q |r |s |t |u |v |w |x |y |z |[ |\ |] |↑ |← | |||||||||||||||
| Template:Chset-left1 | \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |
Control characters
Although graphical characters largely remained uniform across various Commodore machines, the implementation of control characters exhibited notable differences. The following table provides an overview of control character roles for the Commodore PET 2001, Commodore PET 8032, VIC-20, Commodore 64, Commodore 16, and Commodore 128 in both 40 and 80 column configurations.
| Hexadecimal notation | Decimal value | PET 2001 | PET 8032 | VIC-20 | C64 | C16 | C128 (40 columns) | C128 (80 columns) |
|---|---|---|---|---|---|---|---|---|
| 00 | 0 | — | ||||||
| 01 | 1 | — | ||||||
| 02 | 2 | — | Underline ON | |||||
| 03 | 3 | colspan=7 STOP key | ||||||
| 04 | 4 | — | ||||||
| 05 | 5 | — | colspan=5 WHITE color | |||||
| 06 | 6 | — | ||||||
| 07 | 7 | — | BELL signal | — | colspan=2 BELL signal | |||
| 08 | 8 | — | colspan=3 LOCK CASE function | — | ||||
| 09 | 9 | — | TAB character | colspan=3 UNLOCK CASE function | colspan=2 TAB character | |||
| 0A | 10 | — | colspan=2 LINE FEED | |||||
| 0B | 11 | — | colspan=2 UNLOCK CASE | |||||
| 0C | 12 | — | colspan=2 LOCK CASE | |||||
| 0D | 13 | colspan=7 RETURN (Carriage return) | ||||||
| 0E | 14 | — | colspan=6 LOWER CASE mode | |||||
| 0F | 15 | — | SET WINDOW TOP function | — | FLASH ON | |||
| 10 | 16 | — | ||||||
| 11 | 17 | colspan=7 CURSOR DOWN key | ||||||
| 12 | 18 | colspan=7 REVERSE video ON | ||||||
| 13 | 19 | colspan=7 HOME key | ||||||
| 14 | 20 | colspan=7 DELETE (Backspace) | ||||||
| 15 | 21 | — | KILL LINE command | — | ||||
| 16 | 22 | — | ERASE TO RIGHT command | — | ||||
For a detailed explanation of the VIC-20 and C64/128 color codes, refer to the MOS Technology VIC-II#Colors article.
Base 128
Among the initial 192 PETSCII codes, 128 are graphic symbols (ranging from 32–127 and 160–192), which facilitates "base128"-style encoding within DATA statements or communication between PETSCII-compatible devices. This group also includes control codes that differ depending on the specific system.
The primary application of Base 128 encoding is found in Commodore BASIC's DATA statements, where it enables efficient binary data storage by encoding seven bits per character. On an 80-character line, after subtracting space for line numbers and the shortened DATA keyword (dA), approximately 73 characters remain available for data. This results in an efficiency close to 79%, which can rise to around 80% or even 82% when shorter line numbers are used.
| Line Numbers | Data Characters per Line | Bits per Line | Efficiency | Maximum Lines | Maximum Total Data Bytes |
|---|---|---|---|---|---|
| 1-9 | 76 | 532 | 0.83125 | 9 | 598 |
| 10-99 | 75 | 525 | 0.820312 | 90 | 5,906 |
| 100-999 | 74 | 518 | 0.809375 | 900 | 58,275 |
| 1000-9999 | 73 | 511 | 0.7984375 | 9,000 | 574,875 |
| 10000-65535 | 72 | 504 | 0.7875 | 55,536 | ~3.5 MB |
For storing binary data within Commodore BASIC, utilizing two- or three-digit line numbers typically provides optimal encoding efficiency.
Base 164
Since quoted strings can represent up to 164 PETSCII characters—including color codes, function keys, and cursor control sequences—Base 164 encoding is theoretically achievable.
See also
External links
- PETSCII to Unicode mapping along with a TrueType font based on that mapping
- Typography in 8 bits: System fonts
- Online PETSCII-art editor
- PETSCII-art