First page Back Continue Last page Overview Graphics
Run-Length Encoding
AAAAAAA would be encoded as *A7
*n5*x9ccc*h6 some other text *k8eee would be decoded into the following original text
nnnnnxxxxxxxxxccchhhhhh some other text kkkkkkkkeee
The original text contains 51 characters, and the encoded string contains 35 characters, giving us a compression ratio in this example of 35/51 or approximately 0.68.
Since we are using one character for the repetition count, it seems that we can’t encode repetition lengths greater than nine. Instead of interpreting the count character as an ASCII digit, we could interpret it as a binary number.