# National Replacement Character Set Mode (DECNRCM)

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

- **Sequence:** `CSI ? 42 h`
- **Defaults:** reset
- **DEC STD 070:** [§5.8.2 Set/Reset Character Set Mode, p. 5-126](https://archive.org/details/bitsavers_decstandar0VideoSystemsReferenceManualDec91_74264381/page/n380/mode/1up)
- **VT510:** [DECNRCM—National Replacement Character Set Mode](https://vt100.net/docs/vt510-rm/DECNRCM.html)

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](https://control-codes.page/c0/so/index.html.md), 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`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/charproc.c#L1825-L1839)),
German `ESC ( K` among them, and designation skips any such set unless the
mode is set ([`xtermDecodeSCS`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/charproc.c#L1915-L1929)). 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`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/charsets.h#L319-L329)). The mode itself is set and
reported at level 2 and up
([`charproc.c`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/charproc.c#L7680-L7686),
[`do_dec_rqm`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/misc.c#L5572-L5578)). In UTF-8 mode, xterm also switches its
UTF-8 decoding while the mode is set ([`modified_DECNRCM`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/charproc.c#L1288-L1301)).

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](https://control-codes.page/csi/decrqm/index.html.md) 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.

## Validation

### DECNRCM-1: Reset by default

*A known difference: libghostty-vt does not pass this case.*

Input, one step per line:

```text
\e[?42$p
```

Expected screen:

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

### DECNRCM-2: Set

*A known difference: libghostty-vt does not pass this case.*

Input, one step per line:

```text
\e[?42h
\e[?42$p
```

Expected screen:

```text
|_____|
reply \e[?42;1$y
```

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

Input, one step per line:

```text
\e(K      # German into G0
[\\]
```

Expected screen:

```text
|[\]__|
```

### DECNRCM-4: And used once it is set

*A known difference: libghostty-vt does not pass this case.*

Input, one step per line:

```text
\e[?42h
\e(K      # German into G0
[\\]{|}~
```

Expected screen:

```text
|ÄÖÜäöüß_|
```

### DECNRCM-5: The United Kingdom set needs no mode

Input, one step per line:

```text
\e(A      # United Kingdom into G0
\#
```

Expected screen:

```text
|£____|
```

---

This is the Markdown version of <https://control-codes.page/modes/decnrcm/>. On that page every validation case runs live in libghostty-vt, the terminal emulation core of Ghostty, compiled to WebAssembly.

The validation cases are written in the notation described in <https://control-codes.page/notation/index.html.md>.
