Class ASCII85InputStream

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.jpedal.io.filter.ASCII85InputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class ASCII85InputStream extends FilterInputStream
An input stream that decodes bytes from an ASCII string using the ASCII 85 filter

ASCII base-85 decoding shall produce 4 bytes of binary data for every 5 ASCII characters.
Each group of 5 output bytes (c1, c2, c3, c4, c5) shall be converted to a group of 4 binary input bytes (b1, b2, b3, b4) using the relation:


  (b1 * 256^3) + (b2 * 256^2) + (b3 * 256) + b4
      = (c1 * 85^4) + (c2 * 85 ^ 3) + (c3 * 85^2) + (c4 * 85) + c5
 
In other words, 1 ascii z character will be reinterpreted as 5 0 numbers or 5 ASCII in the range 33 (!) to 117 (u) characters will each subtract 33 (the ASCII code for the character !), the resulting numbers from either of these will then be interpreted as a single base-85 number. This will then be converted to a base 256 number, the bytes of which will be the 4 output bytes

If the length of the data to be decoded is not a multiple of 5 bytes, the last, partial group of 5 shall be used to produce a last, partial group of 4 output characters. Given n (1, 2, 3, or 4) bytes of binary data, the decoder shall first append 5 - n zero bytes to make a complete group of 5. It shall decode this group in the usual way. Finally, it shall read only the first n - 1 characters of the resulting group of 4.
- PDF Spec ISO 32000-2