millfork

Millfork: a middle-level programming language targeting 6502- and Z80-based microcomputers and home consoles

This project is maintained by KarolS

< back to index

Text encodings and escape sequences

Defining custom encodings

Every platform is defined in an .tbl file with an appropriate name. The file is looked up in the directories on the include path, first directly, then in the encoding subdirectory.

TODO: document the file format.

Text encoding list

When programming for Commodore, use petscii for strings you’re printing using standard I/O routines and petsciiscr for strings you’re copying to screen memory directly.

When programming for Atari, use atascii for strings you’re printing using standard I/O routines and atasciiscr 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
Available only in some encodings
Character availability

For ISO/DOS/Windows/UTF encodings, consult external sources.

Encoding lowercase letters backslash currencies intl card suits
pet, yes¹ no £ none yes¹
origpet yes¹ yes   none yes¹
oldpet yes² yes   none yes²
petscr yes¹ no £ none yes¹
petjp no no ¥ katakana³ yes³
petscrjp no no ¥ katakana³ yes³
geos_de yes no     no
sinclair, bbc yes yes £ none no
zx80, zx81 no no £ none no
apple2 no yes   none no
atascii yes yes   none yes
atasciiscr yes yes   none yes
z1013 yes yes   none yes
jis yes no ¥ both kana no
dmcs,lics yes yes ¢£¥ Western no
brascii,macroman yes yes ¢£¥ Western no
msx_intl,msx_br yes yes ¢£¥ Western yes
msx_jp yes no ¥ katakana yes
msx_ru yes yes   Russian⁴ yes
koi7n2 no yes   Russian⁵ no
koi8* yes yes   Russian no
cpc_en yes yes £ none yes
cpc_es yes yes   Spanish⁶ yes
cpc_fr yes no £ French⁷ yes
cpc_da yes no £ Nor/Dan. yes
vectrex no yes   none no
coco,cocoscr no yes   none no
pokemon1jp no no   both kana no
pokemon1en yes no   none no
pokemon1fr yes no   Ger/Fre. no
pokemon1es yes no   Spa/Ita. no
galaksija no no   Yugoslav⁸ no
  1. pet, origpet and petscr 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.

  2. 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.

  3. petjp and petscrjp 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.

  4. Letter Ё and uppercase Ъ are not available.

  5. Only uppercase. Letters Ё and Ъ are not available.

  6. No accented vowels.

  7. Some accented vowels are not available.

  8. Letter Đ is not available.

If the encoding does not support lowercase letters (e.g. apple2, petjp, petscrjp, koi7n2, vectrex), then text and character literals containing lowercase letters are automatically converted to uppercase. Only unaccented Latin and Cyrillic letters will be converted as such. Accented Latin letters will not be converted and will fail to compile without -flenient-encoding.
To detect if your default encoding does not support lowercase letters, test 'A' == 'a'.

Escape sequence availability

The table below may be incomplete.

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
geos_de no no no no no yes no
sinclair yes yes no yes yes yes yes
zx80,zx81 yes no yes yes no no no
ascii, iso_* yes yes yes no no no no
iso8869_*, cp* yes yes yes no no no no
apple2 no yes no no no no no
apple2 no no no no no no no
apple2e no yes no no no no no
apple2gs no yes no no no no no
atascii yes no yes yes no no no
atasciiscr no no no no no no no
msx_* yes yes yes yes no no no
koi7n2 yes no yes no no no no
koi8* yes yes yes no no no no
vectrex no no no no no no no
coco yes no yes no no no no
cocoscr no no no no no no no
utf* yes yes yes no no no no
all the rest yes yes no no no no no