Class QrSegment (original) (raw)

Represents a segment of character/binary/control data in a QR code symbol.

Inheritance

System.Object

QrSegment

Inherited Members

System.Object.Equals(System.Object)

System.Object.Equals(System.Object, System.Object)

System.Object.GetHashCode()

System.Object.GetType()

System.Object.MemberwiseClone()

System.Object.ReferenceEquals(System.Object, System.Object)

System.Object.ToString()

Namespace: Net.Codecrete.QrCodeGenerator
Assembly: QrCodeGenerator.dll
Syntax

Constructors

| Improve this Doc View Source

QrSegment(QrSegment.Mode, Int32, BitArray)

Initializes a QR code segment with the specified attributes and data.

The character count numChars must agree with the mode and the bit array length, but the constraint isn't checked. The specified bit array is cloned.

Declaration
public QrSegment(QrSegment.Mode mode, int numChars, BitArray data)
Parameters
Type Name Description
QrSegment.Mode mode The segment mode used to encode this segment.
System.Int32 numChars The data length in characters or bytes (depending on the segment mode).
System.Collections.BitArray data The data bits.
Exceptions
Type Condition
System.ArgumentNullException mode or data is null.
System.ArgumentOutOfRangeException numChars is negative.

Properties

| Improve this Doc View Source

EncodingMode

The encoding mode of this segment.

Declaration
public QrSegment.Mode EncodingMode { get; }
Property Value
Type Description
QrSegment.Mode Encoding mode.

| Improve this Doc View Source

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.

Different from the data's bit length.

Declaration
public int NumChars { get; }
Property Value
Type Description
System.Int32 Length of the segment's unencoded data.

Methods

| Improve this Doc View Source

GetData()

Returns a copy of this segment's data bits.

Declaration
public BitArray GetData()
Returns
Type Description
System.Collections.BitArray A copy of the data bits.

| Improve this Doc View Source

IsAlphanumeric(String)

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

A string is encodable iff each character is in the range "0" to "9", "A" to "Z" (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.

Declaration
public static bool IsAlphanumeric(string text)
Parameters
Type Name Description
System.String text the string to test for encodability (not null)
Returns
Type Description
System.Boolean true iff each character is in the alphanumeric mode character set.
Exceptions
Type Condition
System.NullReferenceException if the string is null
See Also

| Improve this Doc View Source

IsNumeric(String)

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

A string is encodable iff each character is in the range "0" to "9".

Declaration
public static bool IsNumeric(string text)
Parameters
Type Name Description
System.String text the string to test for encodability (not null)
Returns
Type Description
System.Boolean true iff each character is in the range "0" to "9".
Exceptions
Type Condition
System.NullReferenceException if the string is null
See Also

| Improve this Doc View Source

MakeAlphanumeric(String)

Creates a segment representing the specified text string. The segment is encoded in alphanumeric mode.

Allowed characters are: 0 to 9, A to Z (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.

Declaration
public static QrSegment MakeAlphanumeric(string text)
Parameters
Type Name Description
System.String text The text to encode, consisting of allowed characters only.
Returns
Type Description
QrSegment The created segment containing the text.
Exceptions
Type Condition
System.ArgumentNullException text is null.
System.ArgumentOutOfRangeException text contains non-encodable characters.

| Improve this Doc View Source

MakeBytes(Byte[])

Creates a segment representing the specified binary data encoded in byte mode. All input byte arrays are acceptable.

Any text string can be converted to UTF-8 bytes (using Encoding.UTF8.GetBytes(str)) and encoded as a byte mode segment.

Declaration
public static QrSegment MakeBytes(byte[] data)
Parameters
Type Name Description
System.Byte[] data The binary data to encode.
Returns
Type Description
QrSegment The created segment containing the specified data.
Exceptions
Type Condition
System.ArgumentNullException data is null.

| Improve this Doc View Source

MakeEci(Int32)

Creates a segment representing an Extended Channel Interpretation (ECI) designator with the specified assignment value.

Declaration
public static QrSegment MakeEci(int assignVal)
Parameters
Type Name Description
System.Int32 assignVal The ECI assignment number (see the AIM ECI specification).
Returns
Type Description
QrSegment The created segment containing the data.
Exceptions
Type Condition
System.ArgumentOutOfRangeException assignValis outside the range [0, 106).

| Improve this Doc View Source

MakeNumeric(String)

Creates a segment representing the specified string of decimal digits. The segment is encoded in numeric mode.

Declaration
public static QrSegment MakeNumeric(string digits)
Parameters
Type Name Description
System.String digits The text to encode, consisting of digits from 0 to 9 only.
Returns
Type Description
QrSegment The created segment containing the text.
Exceptions
Type Condition
System.ArgumentNullException digits is null.
System.ArgumentOutOfRangeException digits contains non-digit characters

| Improve this Doc View Source

MakeSegments(String)

Creates a list of zero or more segments representing the specified text string.

The text may contain the full range of Unicode characters.

The result may multiple segments with various encoding modes in order to minimize the length of the bit stream.

Declaration
public static List<QrSegment> MakeSegments(string text)
Parameters
Type Name Description
System.String text The text to be encoded.
Returns
Type Description
System.Collections.Generic.List<QrSegment> The created mutable list of segments representing the specified text.
Exceptions
Type Condition
System.ArgumentNullException text is null.