^[control-codes
live in libghostty-vt

Private modes

DECNRCM National Replacement Character Set Mode

View as Markdown

Allow the 7-bit national character sets, which replace a few ASCII characters with letters of one language.

CSI ? 42 h/l
Defaults
reset
DEC STD 070
§5.8.2 Set/Reset Character Set Mode, p. 5-126
VT220
§4.6.19 Character Set Mode (DECNRCM)
VT510
DECNRCM—National Replacement Character Set Mode

Before 8-bit character sets, each country had a 7-bit national replacement character set: ASCII with a dozen of its characters, such as [, \ and ], replaced by letters the language needs. German, for instance, has Ä, Ö and Ü in their places. Mode 42 chooses between those and the 8-bit multinational sets. Reset, the default, the terminal uses the multinational sets; set (CSI ? 42 h), a national set can be designated with SCS, the same way any other set is.

In xterm, the national sets that need the mode are refused while it is reset. Its table of designations marks each one (charproc.c), German ESC ( K among them, and designation skips any such set unless the mode is set (xtermDecodeSCS). The United Kingdom set, ESC ( A, which replaces # with £, came with the VT100 and needs no mode. With the mode set, German maps [, \, ], {, |, } and ~ to Ä, Ö, Ü, ä, ö, ü and ß (charsets.h). The mode itself is set and reported at level 2 and up (charproc.c, do_dec_rqm). In UTF-8 mode, xterm also switches its UTF-8 decoding while the mode is set (modified_DECNRCM).

DEC STD 070 adds that changing the mode puts every designated and invoked character set back to its default, and that the national set used comes from the keyboard dialect chosen in Set-Up. xterm does not reset the sets when the mode changes, and the cases follow xterm.

libghostty-vt does not have the mode: mode 42 is not in its table in modes.zig, so DECRQM reports it as not recognized (0). It also has no national sets at all: charsets.zig knows only UTF-8, ASCII, the United Kingdom set and DEC Special Graphics. Three cases are known differences.

Support

TerminalVersionSupportNotes
VT220manual, 2nd ed., 1984Yes§4.6.19 Character Set Mode (DECNRCM)
VT510manual, 1st ed., 1993YesDECNRCM
xtermpatch 412, xterm-411aYesdoes not reset the character sets when the mode changes
libghostty-vt0f171f6Nono mode 42 and no national sets (DECNRCM-1, DECNRCM-2, DECNRCM-4)
kitty0.49.1, run in a VMNofails the 3 cases that show it working
foot1.28.0, run in a VMNofails the 3 cases that show it working
pyte0.8.2, run as a libraryNofails the case that shows it working
xterm.js headless6.0.0, run as a libraryPartlyfails DECNRCM-1, DECNRCM-2 of the 3 cases that show it working
alacritty_terminal0.26.0, run as a libraryNofails the 3 cases that show it working
ConEmubuild 230724, its documentationNonot in ConEmu’s list, ANSI escape codes
rxvt-unicode9.31, run in a VMNofails the 3 cases that show it working
VTE0.84.1, run as a libraryNofails the 3 cases that show it working

Validation

DECNRCM-1: Reset by default

\e[?42$p
|_____|
reply \e[?42;2$y

DECNRCM-2: Set

\e[?42h
\e[?42$p
|_____|
reply \e[?42;1$y

DECNRCM-3: German is refused while the mode is reset

\e(K      # German into G0
[\\]
|[\]__|

DECNRCM-4: And used once it is set

\e[?42h
\e(K      # German into G0
[\\]{|}~
|ÄÖÜäöüß_|

DECNRCM-5: The United Kingdom set needs no mode

\e(A      # United Kingdom into G0
\#
|£____|
Every example on these pages runs in your browser, in libghostty-vt compiled to WebAssembly.