LZW compression from the original Unix compress utility.
Overview
A .Z file begins with 1F 9D and a flags byte (maximum code width 9-16 bits, block mode bit). Codes are packed LSB first in groups, with width increases and an optional clear code in block mode. There is no checksum.
Where it is used
Old Unix archives (.tar.Z) and legacy software.
History
Written for Unix in 1984 (Spencer Thomas, Joe Orost and others); LZW patent issues led to gzip.
Status today
Obsolete; encountered in old archives.
Structures read by the implementation
Offsets are in bytes from the start of the buffer named in each heading. Field names are taken from the implementation and are not an official specification. Fixed-width integers are shown as u/i (unsigned/signed) followed by bit width and byte order.
Stop.Carve buffer stack ยท UnixCompressCarver.cs
Offset
Size
Type
Field
Notes
0x0
1
bytes
โ
0x0
1
u8
โ
Constants
General UnixCompressCarver
Name
Value
Type
Notes
TableSize
1 << 16
int
ClearCode
256
int
SectorSize
512
int
General LzwBits
Name
Value
Type
Notes
ZeroRunEnd
64 * 1024
int
Implementation limits reader
Class
Name
Value
Notes
UnixCompressCarver
MaxTarPadding
64L * 1024 * 1024
UnixCompressCarver
MinPlainOutput
512
LzwBits
ChunkSize
256 * 1024
Stop enum
Name
Value
EndOfData
(next)
ZeroSector
(next)
BadCode
(next)
TarEnd
(next)
Unreadable
(next)
Limit
(next)
Structures and constants were extracted from: Carving/Plugins/Compressed/UnixCompressCarver.cs, Modules/FileSystems/UnixCompressArchiveModule.cs. Prose sections are a summary from public sources; verify details before relying on them.