RLE90

RLE90 is a run-length encoding data compression scheme used in several file formats, either by itself, or as part of a more sophisticated compression scheme. It is only occasionally called RLE90, but its other names, such as "Packed" and "RLE", are hopelessly vague.

The format is simple, but is more stateful than most RLE schemes, and has edge cases that can lead to problems. It uses byte value 0x90 (decimal 144) as an escape code.

Format details
To decompress:

Read the next byte(s). Follow the instructions in the first row of this table that matches. Repeat.

The term "previous byte" needs clarification when the previous bytes were the  escape code, or at the beginning of data where there was no previous byte. Some RLE90 variants handle these cases differently than others, by accident or design.

Related formats
Among the formats that may use RLE90 are ARC (and Spark and ArcFS), StuffIt, and BinHex.

Links

 * Rle90Algorithm - A brief description
 * See also the BinHex 4.0 specification