PETSCII

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Shlomital (talk | contribs) at 15:24, 29 September 2004 (added about duplicate range). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Jump to navigation Jump to search

PETSCII (PET Standard Code of Information Interchange), also known as CBM ASCII, is the variation of the ASCII character set used in Commodore (CBM)'s 8-bit home computers, starting with the PET from 1977 and including the VIC-20, C64, Plus/4, C16 and C128.*

PETSCII is based on the 1963 version of ASCII rather than the 1967 version, of which all modern character sets are supersets. As such, PETSCII has only uppercase letters, an up-arrow (↑) instead of a caret (^) in position 0x5E† and a left-arrow (←) instead of an underscore ( _ ) in position 0x5F. In unshifted mode, codes 0x60–0x7F and 0xA0–0xFF are allotted to CBM-specific block graphics characters (horizontal and vertical lines, hatches, shades, triangles, circles and card suites). Ranges 0x00–0x1F and 0x80–0x9F have control codes. The characters in positions 0x60–0x7F repeat themselves in positions 0xC0–0xDF, as do 0xA0–0xBE in 0xE0–0xFE.

PETSCII also has a shifted mode, in which the range 0x41–0x5A has lowercase letters (instead of uppercase in unshifted mode), and the range 0x61–0x7A (and its duplicate 0xC1–0xDA) has uppercase letters (instead of the block graphics). This is in reverse to ASCII-1967, so any text transfer between an 8-bit Commodore machine and one that uses standard ASCII would result in reverse-case text upon arrival to the destination. Thus, like for other computers based on non-standard-ASCII character sets, software conversion is needed when exchanging text files and/or telecommunicating with standard ASCII systems. The other ranges are unchanged in shifted mode.

Included in PETSCII are cursor and screen control codes, such as {HOME}, {CLR}, {RVS ON}, and {RVS OFF} (the latter two activating/deactivating reverse-video character display). The control codes appeared in program listings as reverse-video graphic characters, although some computer magazines, in their efforts to provide more clearly readable listings, pretty-printed the codes using their actual names, like the above examples. The screen control codes were essentially similar to escape codes for text based computer terminals.

As indicated above, PETSCII provides for shifting between the power-on default (unshifted) uppercase+graphics character set and the alternative (shifted) lower+uppercase set (where the shifted set contains a subset of the block graphic characters of the unshifted set). The shift between modes is done via special control codes. Thus, screen editor state changes, rather than the employment of separate ASCII codes, are used to choose between single-case (all capitals) and dual case. In the VIC-20, C64, and later machines (not including the CBM business computers), color codes supplement the other screen control codes. (The colors of the VIC-20 and C64/128 are listed in the C64 article.)

Mapping PETSCII to Unicode is impossible, since not all PETSCII graphics characters are encoded in Unicode. Unmappable characters should be replaced by the Unicode replacement character, U+FFFD (�), or mapped to the private-use range of Unicode.

(* The Amiga computers used standard ASCII. )
(† The 0x-notation, borrowed from C, designates hexadecimal numbers. )

See also: ATASCII, Spectrum Character Set