A Page Whose Letters Cost One Byte Each

A bank that prints two million statements a night pays for every byte twice over: once on the disc the run is kept on, once on the network it travels down. A letter is normally written into a file as a pair of bytes, because that is what it takes to reach any letter of any alphabet on earth. A statement in French needs a hundred or so of them, and the second byte is a nought on every single letter of the run.

Told to, the engine settles a number of its own for each letter a document uses, writes the list of them into the file so reading software knows what it is looking at, and then spends one byte a letter instead of two. The page shows the three lines drawn both ways and prints what each way came to, counted as the page was drawn. It ends on what the short way buys besides room: the space between words becomes something a document can widen, which is how justified text is set, and which the long way has no way of reaching. A last line, in Cyrillic, goes through a table of one-byte codes named by its standard, Windows code page 1251, which reading software already knows.

What This Example Shows

  • One byte a letter instead of two, on every line of the run.
  • The file carries its own list of what each number stands for.
  • The space between words becomes something a line can widen.

The Source Code, Complete

Nothing is left out and nothing is simplified: this is the program exactly as it runs, for the developer who uses this library. The third is the description itself: a plain list of what the page has to say, which is what the service is sent.

Read the Rust source Read the Python source Read the JSON source

The Document Itself

Open the document in English Open the document in French Open the document in German Open the document in Spanish Open the document in Italian Open the document in Portuguese

Examples Near This One

A Minimal PDF

Two identical pages that draw the structure of an invoice with lines and rectangles, without a word of text: the file is about a dozen kilobytes and embeds no font.

Showing Page One Before the File Has Arrived

The same document written twice: once as it is, once with its first page placed at the start of the file. The page gives, for each of the two, the number of bytes a browser must have received before it shows page 1.

Every Paper Size, on Its Own Page

One page for each paper size the library names, from A0 down to A6 and the American sizes, each giving its size in millimetres and inches; then pages laid on their side or upside down, and a banner ten metres long.

A Document That Reads Freely and Asks Not to Be Copied

A page that opens without a password and prints like any other, but asks the reading software to forbid copying and pasting its text. The text is encrypted in the file: a program reading it byte by byte finds no sentence in it.

Every example, by subject