Table of Contents

Class QrSegmentAdvanced

Namespace
Net.Codecrete.QrCodeGenerator
Assembly
QrCodeGenerator.dll

Advanced methods for encoding QR codes using Kanji mode or using multiple segments with different encodings.

public static class QrSegmentAdvanced
Inheritance
QrSegmentAdvanced
Inherited Members

Methods

IsEncodableAsKanji(string)

Tests whether the specified string can be encoded as a segment in Kanji mode.

Broadly speaking, the set of encodable characters are Kanji used in Japan, Hiragana, Katakana, East Asian punctuation, full-width ASCII, Greek, and Cyrillic. Examples of non-encodable characters include ordinary ASCII, half-width Katakana, more extensive Chinese Hanzi.

public static bool IsEncodableAsKanji(string text)

Parameters

text string

The text to test for encodability.

Returns

bool

true iff each character is in the Kanji mode character set.

Exceptions

ArgumentNullException

text is null.

MakeKanji(string)

Creates a segment encoding the specified text in Kanji mode.

Broadly speaking, the set of encodable characters are Kanji used in Japan, Hiragana, Katakana, East Asian punctuation, full-width ASCII, Greek, and Cyrillic. Examples of non-encodable characters include ordinary ASCII, half-width Katakana, more extensive Chinese Hanzi.

public static QrSegment MakeKanji(string text)

Parameters

text string

The text to encoding, containing only characters allowed by the Kanji encoding.

Returns

QrSegment

The created segment representing the specified text.

Exceptions

ArgumentNullException

text is null.

ArgumentOutOfRangeException

text contains non-encodable characters.

See Also

MakeSegmentsForMultipleCodes(string, Ecc, int)

Creates the segments for multiple QR codes for the specified text.

The result will consist of the minimal number of QR codes needed to encode the text with the given error correction level and version (size of QR code). If multiple QR codes are required, Structured Append data is included to link the QR codes.

Each QR code might use multiple segments with different encoding modes to maximize the amount of text that can be stored in each QR code.

The outer list represents the series of QR codes to be created. The inner lists contains the QR segments for each QR code.

Each QR code will contain a valid string as it is ensured that splitting only occurs at character boundaries and not in the middle of a multi-byte encoding of a character. This increases compatibility with QR code scanners that incorrectly assume that each individual QR code in the series contains a valid UTF-8 string.

public static List<List<QrSegment>> MakeSegmentsForMultipleCodes(string text, QrCode.Ecc ecl, int version = 29)

Parameters

text string

The text to be encoded. The full range of Unicode characters may be used.

ecl QrCode.Ecc

The minimum error correction level to use.

version int

The version (size of QR code) to use. Default is 29.

Returns

List<List<QrSegment>>

A list of list of QR segments representing the specified text.

MakeSegmentsOptimally(string, Ecc, int, int)

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

This function potentially uses all four text encoding modes: numeric, alphanumeric, byte (UTF-8), and Kanji. It is a more sophisticated but slower replacement for MakeSegments(string).

The text to be encoded can contain the full set of Unicode characters (code points).

public static List<QrSegment> MakeSegmentsOptimally(string text, QrCode.Ecc ecl, int minVersion = 1, int maxVersion = 40)

Parameters

text string

The text to be encoded.

ecl QrCode.Ecc

The error correction level to use.

minVersion int

The minimum version (size) of the QR code (between 1 and 40).

maxVersion int

The maximum version (size) of the QR code (between 1 and 40).

Returns

List<QrSegment>

The created mutable list of segments encoding the specified text with a minimal bit length.

Exceptions

ArgumentNullException

text or ecl is null.

ArgumentOutOfRangeException

1 ≤ minVersion ≤ maxVersion ≤ 40 is violated.

DataTooLongException

The text is too long to fit into the QR code with the given encoding parameters.

See Also