5.6 KiB
Text encodings ans escape sequences
Text encoding list
-
default
– default console encoding (can be omitted) -
scr
– default screencodes (usually the same asdefault
, a notable exception are the Commodore computers) -
ascii
– standard ASCII -
pet
orpetscii
– PETSCII (ASCII-like character set used by Commodore machines from VIC-20 onward) -
petjp
orpetsciijp
– PETSCII as used on Japanese versions of Commodore 64 -
origpet
ororigpetscii
– old PETSCII (Commodore PET with original ROMs) -
oldpet
oroldpetscii
– old PETSCII (Commodore PET with newer ROMs) -
cbmscr
orpetscr
– Commodore screencodes -
cbmscrjp
orpetscrjp
– Commodore screencodes as used on Japanese versions of Commodore 64 -
apple2
– Apple II charset ($A0–$DF) -
bbc
– BBC Micro character set -
sinclair
– ZX Spectrum character set -
jis
orjisx
– JIS X 0201 -
iso_de
,iso_no
,iso_se
,iso_yu
– various variants of ISO/IEC-646 -
iso_dk
,iso_fi
– aliases foriso_no
andiso_se
respectively -
msx_intl
,msx_jp
,msx_ru
– MSX character encoding, International, Japanese and Russian respectively -
msx_us
,msx_uk
,msx_fr
,msx_de
– aliases formsx_intl
-
atascii
oratari
– ATASCII as seen on Atari 8-bit computers -
atasciiscr
oratariscr
– screencodes used by Atari 8-bit computers -
vectrex
– built-in Vectrex font
When programming for Commodore,
use pet
for strings you're printing using standard I/O routines
and petscr
for strings you're copying to screen memory directly.
Escape sequences
Escape sequences allow for including characters in the string literals that would be otherwise impossible to type.
Some escape sequences may expand to multiple characters. For example, in several encodings {n}
expands to {x0D}{x0A}
.
Available everywhere
-
{q}
– double quote symbol -
{apos}
– apostrophe/single quote -
{x00}
–{xff}
– a character of the given hexadecimal value -
{copyright_year}
– this expands to the current year in digits -
{program_name}
– this expands to the name of the output file without the file extension -
{program_name_upper}
– the same, but uppercased
Available only in some encodings
-
{n}
– new line -
{b}
– backspace -
{lbrace}
,{rbrace}
– opening and closing curly brace (only in encodings that support braces) -
{up}
,{down}
,{left}
,{right}
– control codes for moving the cursor -
{white}
,{black}
,{red}
,{green}
,{blue}
,{cyan}
,{yellow}
,{purple}
– control codes for changing the text color -
{bgwhite}
,{bgblack}
,{bgred}
,{bggreen}
,{bgblue}
,{bgcyan}
,{bgyellow}
,{bgpurple}
– control codes for changing the text background color -
{reverse}
,{reverseoff}
– inverted mode on/off -
{yen}
,{pound}
,{copy}
– yen symbol, pound symbol, copyright symbol
Character availability
Encoding | lowercase letters | backslash | pound | yen | katakana | card suits |
---|---|---|---|---|---|---|
pet , origpet |
yes¹ | no | no | no | no | yes¹ |
oldpet |
yes² | no | no | no | no | yes² |
petscr |
yes¹ | no | yes | no | no | yes¹ |
petjp |
no | no | no | yes | yes³ | yes³ |
petscrjp |
no | no | no | yes | yes³ | yes³ |
sinclair , bbc |
yes | yes | yes | no | no | no |
apple2 |
no | yes | no | no | no | no |
atascii |
yes | yes | no | no | no | yes |
atasciiscr |
yes | yes | no | no | no | yes |
jis |
yes | no | no | yes | yes | no |
msx_intl |
yes | yes | yes | yes | no | yes |
msx_jp |
yes | no | no | yes | yes | yes |
msx_ru |
yes | yes | no | no | no | yes |
vectrex |
no | yes | no | no | no | no |
all the rest | yes | yes | no | no | no | no |
-
pet
,origpet
andpetscr
cannot display card suit symbols and lowercase letters at the same time. Card suit symbols are only available in graphics mode, in which lowercase letters are displayed as uppercase and uppercase letters are displayed as symbols. -
oldpet
cannot display card suit symbols and lowercase letters at the same time. Card suit symbols are only available in graphics mode, in which lowercase letters are displayed as symbols. -
petjp
andpetscrjp
cannot display card suit symbols and katakana at the same time Card suit symbols are only available in graphics mode, in which katakana is displayed as symbols.
If the encoding does not support lowercase letters (e.g. apple2
, petjp
, petscrjp
),
then text and character literals containing lowercase letters are automatically converted to uppercase.
Escape sequence availability
Encoding | new line | braces | backspace | cursor movement | text colour | reverse | background colour |
---|---|---|---|---|---|---|---|
pet ,petjp |
yes | no | no | yes | yes | yes | no |
origpet |
yes | no | no | yes | no | yes | no |
oldpet |
yes | no | no | yes | no | yes | no |
petscr , petscrjp |
no | no | no | no | no | no | no |
sinclair |
yes | yes | no | yes | yes | yes | yes |
ascii , iso_* |
yes | yes | yes | no | no | no | no |
apple2 |
no | yes | no | no | no | no | no |
atascii |
yes | no | yes | yes | no | no | no |
atasciiscr |
no | no | no | no | no | no | no |
vectrex |
no | no | no | no | no | no | no |
all the rest | yes | yes | no | no | no | no | no |