fn

encodeText

tested

Returns a QR Code representing the given Unicode text string at the given error correction level. As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible QR Code version is automatically chosen for the output.

Signature

ts
export function encodeText(text: string, ecl: QrCodeEcc): QrCode{ ... }

Parameters

ParameterTypeDescription
textstring
eclQrCodeEcc

Returns

QrCode
PropertyTypeDescription
sizenumberThe width and height of this QR Code, measured in modules, between 21 and 177 (inclusive).
masknumberThe index of the mask pattern used in this QR Code, which is between 0 and 7 (inclusive).
modulesUint8ArrayThe modules of this QR Code (0 = light, 1 = dark). Flat row-major Uint8Array.
typesInt8ArrayData type of each module. Flat row-major Int8Array.
versionnumber
eccQrCodeEcc
getModule(x: number, y: number) => booleanReturns the color of the module (pixel) at the given coordinates. false for light, true for dark. Out of bounds returns false (light).
getType(x: number, y: number) => QrCodeDataTypeReturns the data type of the module at the given coordinates.
drawFunctionPatterns() => void
drawFormatBits(mask: number) => void
drawVersion() => void
drawFinderPattern(x: number, y: number) => void
drawAlignmentPattern(x: number, y: number) => void
setFunctionModule(x: number, y: number, isDark: number, type?: QrCodeDataType) => void
addEccAndInterleave(data: readonly number[]) => number[]
drawCodewords(data: readonly number[]) => void
applyMask(mask: number) => void
getPenaltyScore() => number
getAlignmentPatternPositions() => number[]