QrSegment

class QrSegment(val mode: QrSegment.Mode, val numChars: Int, data: BitBuffer)

A segment of character/binary/control data in a QR Code symbol. Instances of this class are immutable.

The mid-level way to create a segment is to take the payload data and call a static factory function such as QrSegment.makeNumeric. The low-level way to create a segment is to custom-make the bit buffer and call the with appropriate values.

This segment class imposes no length restrictions, but QR Codes have restrictions. Even in the most favorable conditions, a QR Code can only hold 7089 characters of data. Any segment longer than this is meaningless for the purpose of generating QR Codes. This class can represent kanji mode segments, but provides no help in encoding them

Parameters

mode

mode indicator of this segment (not null)

numChars

The length of this segment's unencoded data. Measured in characters for numeric/alphanumeric/kanji mode, bytes for byte mode, and 0 for ECI mode. Always zero or positive. Not the same as the data's bit length.

data

the data bits (not null)

Throws

if the mode or data is null

if the character count is negative

Constructors

Link copied to clipboard
constructor(mode: QrSegment.Mode, numChars: Int, data: BitBuffer)

Constructs a QR Code segment with the specified attributes and data. The character count (numCh) must agree with the mode and the bit buffer length, but the constraint isn't checked. The specified bit buffer is cloned and stored.

Types

Link copied to clipboard
object Companion
Link copied to clipboard

Describes how a segment's data bits are interpreted.

Properties

Link copied to clipboard

Returns the data bits of this segment.

Link copied to clipboard
Link copied to clipboard