Ascii85 - Basic Idea

Basic Idea

The basic need for a binary-to-text encoding comes from a need to communicate arbitrary binary data over preexisting communications protocols that were designed to carry only human-readable text. Those communication protocols may only be 7-bit safe (and within that avoid certain ASCII control codes), and may require line breaks at certain maximum intervals, and may not maintain whitespace. Thus, only the 94 printable ASCII characters are "safe" to use to convey data.

4 bytes can represent 232 = 4,294,967,296 possible values. 5 radix-85 digits provide 855 = 4,437,053,125 possible values, enough to provide for a unique representation for each possible 32-bit value. Further, notice that five radix-84 digits provide 845 = 4,182,119,424 representable values. The implication of this is that 85 is the minimum possible integral base that will represent four bytes in five characters, hence its choice.

When encoding, each group of 4 bytes is taken as a 32-bit binary number, most significant byte first (Ascii85 uses a big-endian convention). This is converted, by repeatedly dividing by 85 and taking the remainder, into 5 radix-85 digits. Then each digit (again, most significant first) is encoded as an ASCII printable character by adding 33 to it, giving the ASCII characters 33 ("!") to 117 ("u").

Because all-zero data is quite common, an exception is made for the sake of data compression, and an all-zero group is encoded as a single character "z" instead of "!!!!!".

Groups of characters that decode to a value greater than 232 − 1 (encoded as "s8W-!") will cause a decoding error, as will "z" characters in the middle of a group. White space between the characters is ignored and may occur anywhere to accommodate line-length limitations.

One disadvantage of Ascii85 is that encoded data may contain escape characters such as backslash and quote, which have special meaning in many programming languages and in some text-based protocols.

Read more about this topic:  Ascii85

Famous quotes containing the words basic and/or idea:

    Justice begins with the recognition of the necessity of sharing. The oldest law is that which regulates it, and this is still the most important law today and, as such, has remained the basic concern of all movements which have at heart the community of human activities and of human existence in general.
    Elias Canetti (b. 1905)

    To make our idea of morality centre on forbidden acts is to defile the imagination and to introduce into our judgments of our fellow-men a secret element of gusto.
    Robert Louis Stevenson (1850–1894)