makeSegmentsOptimally

fun makeSegmentsOptimally(text: CharSequence, ecl: QrCode.Ecc, minVersion: Int, maxVersion: Int): MutableList<QrSegment>

Returns a list of zero or more segments to represent the specified Unicode text string. The resulting list optimally minimizes the total encoded bit length, subjected to the constraints in the specified {error correction level, minimum version number, maximum version number}.

This function can utilize all four text encoding modes: numeric, alphanumeric, byte (UTF-8), and kanji. This can be considered as a sophisticated but slower replacement for . This requires more input parameters because it searches a range of versions, like QrCode.encodeSegments.

Return

a new mutable list (not null) of segments (not null) containing the text, minimizing the bit length with respect to the constraints

Parameters

text

the text to be encoded (not null), which can be any Unicode string

ecl

the error correction level to use (not null)

minVersion

the minimum allowed version of the QR Code (at least 1)

maxVersion

the maximum allowed version of the QR Code (at most 40)

Throws

if the text or error correction level is null

if 1 ≤ minVersion ≤ maxVersion ≤ 40 is violated

if the text fails to fit in the maxVersion QR Code at the ECL