---
title: "ITA2"
description: "Baudot-Murray teleprinter code in five bits, with the letters and figures shifts handled for you"
canonical_url: "https://encodings.agntn.dev/encodings/ita2"
---
# ITA2

> Baudot-Murray teleprinter code in five bits, with the letters and figures shifts handled for you

<encoding-facts name="ita2">



</encoding-facts>

ITA2 uses five bits per character. That gives it 32 codes, not enough for letters and digits together. So two of them are shift keys that flip the table.

```ts
encode("ita2", "HELLO");  // "10100 00001 10010 10010 11000"
```

Before `ita2`, reading a telex string meant `binary` with `bits: 5`. You got numbers from 0 to 31 and lost the shift at the first FIGS. Now the library keeps track.

## How do letters and figures shifts work?

Decoding starts in letters. FIGS, `11011`, switches to figures. LTRS, `11111`, switches back.

You never type a shift. The encoder sends FIGS before the `1` and moves on.

```ts
encode("ita2", "A1");                     // "00011 11011 10111"
encode("ita2", "A1", { numbers: true });  // "3 27 23"
```

The numbers form writes each five-bit code as a decimal number. Decoding accepts numbers separated by spaces or commas.

```ts
decode("ita2", "20 1 18 18 24", { numbers: true }).bytes;  // "HELLO"
```

ITU-T S.1 says a message should begin with a shift. The library doesn't add one at the start. It starts in letters instead.

## Which Baudot alphabet should you use?

The `alphabet` option picks the table. Pick the wrong one and old tape still decodes, just with the wrong punctuation.

`ita2` is the default, defined by ITU-T S.1. `us-tty` uses the same letters, but moves figures. Bell moves to S, apostrophe to J, and `$`, `!`, `&`, `#` fill D, F, G, H. V has `;` and Z has a double quote.

```ts
decode("ita2", "11011 10001").bytes;                          // "+"
decode("ita2", "11011 10001", { alphabet: "us-tty" }).bytes;  // "\""
```

`ita1` is Baudot's code as CCITT standardized it in 1929. Its shifts use different codes. Each shift also acts as a space in the other case.

```ts
encode("ita2", "A 1 A");                        // "00011 00100 11011 10111 00100 11111 00011"
encode("ita2", "A 1 A", { alphabet: "ita1" });  // "00001 10000 01000 00001 01000 10000 00001"
```

## Which bit order goes first?

The default `order: "msb"` writes element 5 first, as most tables do. Use `order: "lsb"` to write element 1 first, as S.1 lists it and serial transmission sends it.

```ts
encode("ita2", "HELLO", { order: "lsb" });  // "00101 10000 01001 01001 00011"
```

On paper tape, `1` is a hole and `0` is no hole. Decoding skips ASCII whitespace between bits.

## What does ITA2 refuse?

Lowercase has no code. Teleprinters are firmly on team capitals.

```ts
encode("ita2", "hello");  // throws: ita2: "h" (U+0068) at index 0 has no code in ita2; teleprinters print capitals only
```

The default table has no `!`. US-TTY does.

```ts
encode("ita2", "HI!");                          // throws: ita2: "!" (U+0021) at index 2 has no code in ita2
encode("ita2", "HI!", { alphabet: "us-tty" });  // "10100 00110 11011 01101"
```

S.1 leaves the figures for F, G and H to national use. The decoder reports an unassigned code and its position rather than guessing. A made-up national symbol would be worse than an error.

```ts
decode("ita2", "11011 01101");                                // throws: ita2: code 13 at index 6 means nothing among figures in ita2
decode("ita2", "11011 01101", { alphabet: "us-tty" }).bytes;  // "!"
decode("ita2", "0101");                                       // throws: ita2: 4 bits are not whole groups of 5
```

## Can identify spot ITA2?

`identify` considers ITA2 when the codes produce readable text. A lone NUL isn't enough.

```ts
identify("10100 00001 10010 10010 11000 00100 10011 11000 01010 10010 01001")[0];  // encoding "ita2", text "HELLO WORLD"
```

It doesn't guess the numbers form. Digits alone don't point to five-bit codes. `peel` finds ITA2 under other layers too.

```ts
peel("MTExMDAgMDAwMDEgMDAwMDEgMTAwMDAgMDAxMDAgMDAwMTEgMTAwMDAgMDAxMDAgMTEwMTEgMTAxMTEgMDAxMTEgMTAxMTAgMTAxMTA=").map((layer) => layer.encoding);
// ["base64", "ita2"]
```

The last layer reads `MEET AT 1700`. The shift key made it through Base64 too.

## Controls, aliases and the CLI

CR and LF become `\r` and `\n`. Bell is U+0007. Figures D in ITA2 is WRU, "who are you?", and it comes out as U+0005 ENQ. The all-space null is U+0000.

`baudot` is an alias for `ita2`. For the codec alone, `@agntn/encodings/ita2` exports `ita2` and `ITA2_ALPHABETS`.

In the CLI, `encodings encode ita2 A1` prints `00011 11011 10111`. The flags are `--alphabet`, `--order` and `--numbers`.


## Sitemap

See the full [sitemap](https://encodings.agntn.dev/sitemap.md) for all pages.
