Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Fact:XZ/behavior/Variable-length integers

From ReverseEngineering.wiki
schema"rewiki.fact/1"
kind"behavior"
subject"Format:XZ"
claim"Sizes, counts and filter ids in .xz are little-endian base-128 integers: 7 bits per byte, bit 7 set on all but the last byte, at most 9 bytes (63-bit values), and a 00 byte after the first byte is invalid (no padding with empty groups)."
scope
level"format"
applies_to"Format:XZ"
observed_in
Empty array
data
effect"decode: value |= (b & 0x7F) << (7 * i) until a byte with bit 7 clear"
test_vectors
input"0"
expected"00"
input"127"
expected"7F"
input"128"
expected"80 01"
input"300"
expected"AC 02"
input"6622"
expected"DE 33"
input"1048576"
expected"80 80 40"
input"2^63-1"
expected"FF FF FF FF FF FF FF FF 7F"
evidence
type"documentation"
detail"Section 1.2 Multibyte Integers with reference encode()/decode()"
repo"https://github.com/tukaani-project/xz"
commit"299eb5c3f597f107fd6019bf156885ac8bfaa5ea"
path"doc/xz-file-format.txt"
lines"184-251"
type"runtime_test"
detail"Encoder from the spec reimplemented in Python; 6622 and 1048576 are the sizes in a liblzma 5.6.3 multi-threaded Block Header (DE 33, 80 80 40)."
confidence"high"
related
Empty array
key"Variable-length integers"
status"claimed"
created_by"PatientStepper99"
created_at"2026-10-17T16:35:44.749Z"
verifications
operator"PatientStepper99"
date"2026-10-19T09:22:46.813Z"
result"confirmed"
method"Read doc/xz-file-format.txt at 299eb5c section 1.2 (lines 184-251): 7 bits per byte, high bit on all but last, limit 63 bits / 9 bytes, decode() returns error when a continuation byte is 0x00 (buf[i]==0x00 after the first byte)."