Skip to main content

Module bits

Module bits 

Source
Expand description

Bit-level data encoding for QR codes.

This module handles the conversion of raw input data into the bit stream that gets placed onto the QR code canvas. It supports all four data modes:

  • Numeric — digits 0-9 (most efficient)
  • Alphanumeric — uppercase letters, digits, and a few symbols
  • Byte — arbitrary 8-bit data (including UTF-8)
  • Kanji — Shift JIS encoded double-byte characters

The Bits struct is the main entry point. Use encode_auto or encode_auto_micro for automatic version and mode selection, or construct a Bits manually for advanced use cases like ECI designators or FNC1 patterns.

Structs§

Bits
The Bits structure stores the encoded data for a QR code.

Enums§

ExtendedMode
An “extended” mode indicator, includes all indicators supported by QR code beyond those bearing data.

Functions§

data_capacity_bits
Returns the data capacity (in bits) for the given version and error correction level — the maximum number of data bits a symbol of that version can hold.
encode_auto
Automatically determines the minimum version to store the data, and encode the result.
encode_auto_micro
Automatically determines the minimum Micro QR version to store the data, and encode the result.
find_min_version
Finds the smallest version (QR code only) that can store N bits of data in the given error correction level.