Encoding
Snarl uses a binary-based variable length encoding to represent characters, graphemes, or other elements of a message. In a standard English encoding table, the letters of the Latin alphabet are arranged in descending order of frequency in typical English text. Tables for other languages can be constructed with characters and frequency data from the language in question.
Once the characters have been sorted, each is assigned a binary code. These codes appear to be simple binary numbers, but with one major difference - leading zeroes are not implied. Thus, the codes 1, 01, and 001 are all different. This allows up to 30 characters to be represented by codes 1-4 bits in length. With codes up to 5 bits, the maximum rises to 62.
English Table | |
---|---|
A | 00 |
B | 0101 |
C | 101 |
D | 011 |
E | 0 |
F | 0001 |
G | 0010 |
H | 001 |
I | 10 |
J | 1000 |
K | 0111 |
L | 100 |
M | 111 |
N | 11 |
O | 01 |
P | 0100 |
Q | 1010 |
R | 010 |
S | 000 |
T | 1 |
U | 110 |
V | 0110 |
W | 0000 |
X | 1001 |
Y | 0011 |
Z | 1011 |