Lempel-Ziv-Welch (LZW)

Compression & Decompression Algorithm.

Examples:
Spaces and case count. Enter up to 2,000 UTF-8 bytes.

Text used for these tables

Start with the same dictionary.

Single bytes: 0–255
First new phrase: 256

Build the compression table

Lecture 7 · pp. 40–60

See the actual numeric codes

Size of the complete example

Original text

LZW output

Difference

How to read the notation and dictionary

Notation: a single character such as A in the Output column stands for its numeric code, 65. A learned phrase uses a code such as <256>. The computer sends numbers in both cases.

The dictionary: the encoder and decoder each start with the same 256 single-byte entries. Both build their own new entries. This example does not send the completed dictionary.

Visible whitespace: ␠ = space, ↵ = newline, ⇥ = tab. \xNN shows a non-printable or non-ASCII byte in hexadecimal. Non-ASCII characters can use several UTF-8 bytes.

Initial codes used in this example

Reference: CSE 4295, Lecture 7