BinaryFormat.7BitEncodedUnsignedInteger

Binary

A binary format that reads a 64-bit unsigned integer encoded using a 7-bit variable-length encoding.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

BinaryFormat.7BitEncodedUnsignedInteger(binary as binary) as any

Parameters

NameTypeRequiredDescription
binarybinaryYesThe binary data to read the 7-bit encoded unsigned integer from.

Return Value

functionA binary format function that reads a 7-bit variable-length encoded unsigned integer from binary data.

Remarks

BinaryFormat.7BitEncodedUnsignedInteger is a binary format specifier that reads a 64-bit unsigned integer that was encoded using a 7-bit variable-length encoding. In this encoding, small values use fewer bytes than larger values. Each byte uses 7 bits for data and 1 bit (the high bit) to indicate whether more bytes follow.

This format is commonly found in .NET binary serialization (e.g., BinaryWriter.Write7BitEncodedInt) and is often used to prefix strings or lists with their length in a compact form. Values 0-127 use a single byte, values 128-16383 use two bytes, and so on.

This is a format value (a function), not a function you call directly on data. Use it as a format specifier with other BinaryFormat functions or apply it directly to binary data.

Examples

Example 1: Read a 7-bit encoded unsigned integer

let
    // The value 10 encoded as a single byte (values < 128 fit in one byte)
    binaryData = #binary({0x0A}),
    result = BinaryFormat.7BitEncodedUnsignedInteger(binaryData)
in
    result

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks