# Locking Shift Two and Three (LS2, LS3)

> Switch the characters printed to the G2 or G3 set.

- **Sequence:** `ESC n`
- **ECMA-48:** [§8.3.78 LS2 – Locking-Shift Two, p. 49](https://archive.org/details/ecma-48-5th-edition-june-1991/page/n62/mode/1up)
- **DEC STD 070:** [§3.8.3.1 Locking Shift Two, p. 3-75](https://archive.org/details/bitsavers_decstandar0VideoSystemsReferenceManualDec91_74264381/page/n179/mode/1up)
- **VT510:** [Table 4–8](https://vt100.net/docs/vt510-rm/chapter4.html#T4-8)

LS2 invokes the G2 set into GL, and LS3 (`ESC o`) the G3 set: everything
printed after it comes from that set, until another shift. They do for G2 and
G3 what [SO](https://control-codes.page/c0/so/index.html.md) does for G1, and [SI](https://control-codes.page/c0/so/index.html.md) undoes them by invoking
G0 again. G2 and G3 are filled with `ESC * F` and `ESC + F`.

LS3 is
[ECMA-48 §8.3.80, p. 50](https://archive.org/details/ecma-48-5th-edition-june-1991/page/n63/mode/1up)
and [DEC STD 070 §3.8.3.1, p. 3-76](https://archive.org/details/bitsavers_decstandar0VideoSystemsReferenceManualDec91_74264381/page/n180/mode/1up).
DEC STD 070 says both are there "for interchange compatibility with ISO and
ANSI standards", and that they are "not to be used by conforming software".

LS1R, LS2R and LS3R (`ESC ~`, `ESC }` and `ESC |`) invoke G1, G2 and G3
into GR instead, the right half of the code table, `A1` to `FE`. That half
exists only where the input is 8-bit codes. libghostty-vt decodes its input
as UTF-8, where `A1` to `FE` are not bytes of their own but parts of
multi-byte characters. It accepts the three sequences and records the
choice, but `print` in `Terminal.zig` never consults GR, so they have no
effect.

## Validation

### LS2-1: G2 into GL, then back

Input, one step per line:

```text
\e*0      # G2 is DEC Special Graphics
\en       # LS2
qx
\x0f      # SI: G0 again
q
```

Expected screen:

```text
|─│q_______|
```

### LS2-2: G3 into GL, then back

Input, one step per line:

```text
\e+0      # G3 is DEC Special Graphics
\eo       # LS3
qx
\x0f      # SI: G0 again
q
```

Expected screen:

```text
|─│q_______|
```

### LS2-3: The shift lasts across lines

Input, one step per line:

```text
\e*0      # G2 is DEC Special Graphics
\en       # LS2
q\r\nq
\x0f      # SI
q
```

Expected screen:

```text
|─_________|
|─q________|
```

---

This is the Markdown version of <https://control-codes.page/esc/ls2/>. 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>.
