Table of Contents
The encoder is enhanced with the release of version 5.1. The change enables user to specify encoding modes and specify if the encoder increases size automatically if it determines that the data cannot be encoded with the size specified. No new API is introduced. Instead, the new features are retrofitted into the size ID parameter.
Prior to version 5.1, the size ID parameter allowed is an integer between 0 and 29 which corresponds to 30 datamatrix sizes, or -1/-2 for automatic size selection. In version 5.1, we added option to allow caller application to set additional bits to tune encoder behavior.
An integer on Windows platform is at least 32 bits. The bit numbering starts at zero for the least significant bit (LSB 0). Only 16 bits are used (LSB 15 to LSB 0). Other bits should be set to 0 for the future use.
In order to be backward compatible with existing applications, value -1 and -2 are handled separately. If the two values are encountered, the logic follows the earlier version - automatic size selection and automatic encodation mode selection.
Secondly, the 16 bits are divided into 2 bytes. The first byte, containing LSB 15 to 8, is called modifier byte. The modifier byte specifies additional behaviors of the encoder. The second bye, LSB 7 to 0, specifies the datamatrix size ID.
The 8 bits in the modifier byte are referred bit 7 to bit 0. The below lists the meaning of each bit:
Bit 7: if this bit is set, the encoder should report an error instead of increasing the internal data matrix size if it finds that the size specified cannot encode the data.
Bit 6-4: reserved for the future use and must be set to 0.
Bit 3-0: the value of the four bits determines the encoding mode selection.
Value 0 indicates that encoder selects the encodation mode automatically, with the goal to minimize the size required. This the behavior defined in the ISO standard.
Value 1 indicates that encoder must use C40 encodation mode throughout. If characters that cannot be encoded by C40 is found, the encoder reports an error.
Value 2. Same as value 1, except the encodation mode used is X12.
Value 3. Same as value 1, except the encodation mode used is TEXT.
Value 4. Same as value 1, except the encodation mode used is EDIFACT.
Value 5. Same as value 1, except the encodation mode used is ASCII.
Value 6. Same as value 1, except the encodation mode used is BASE256.
Value 7. Reserved for the future
Value 8 indicates that encoder selects the encodation mode based on Royal Mail MailMark® specification - i.e. use C40 for the first 45 bytes and encode the remaining bytes in automatic encodation selection.
The value of this byte corresponds to datamatrix size. A data matrix symbol may have 30 different sizes, numbered from 0 to 29. Two values, 30 and 31 are supported for automatic size selection behavior.
Value 0-29: the requested datamatrix size. If the bit 7 of the modifier byte is set, the encoder reports an error if the size specified is too small to encode the data. Otherwise, the encoder increases the size automatically.
Value 30: this value means to select the size automatically, started with rectangular shape. The bit 7 of the modifier byte is ignored.
Value 31: this value means to select the size automatically, started with square shape. The bit 7 of the modifier byte is ignored.
Note that value 30 and 31 behavior is different from -1 and -2: value -1 and -2 also indicate automatic encodation mode selection. For value 30 and 31, the encodation mode selection depends on the modifier byte.
The UK Royal Mail uses datamatrix for their MailMark barcodes. However, instead of allowing automatic encodation mode selection, the MailMark type 7, type 9 and type 29 require the first 45 bytes to be encoded in C40 encodation mode. Type 12 barcode requires all the data to be encoded in C40 mode. Prior to 5.1, our encoder is set to automatic mode selection and therefore produces datamatrix barcodes that are more compact but not compatible with the requirements.
With the release of version 5.1, users can create MailMark barcodes with size ID parameter set according to the table below.
Table C.1. Size ID value for MailMark barcodes
Barcode Type | Size ID | Comment |
---|---|---|
2D CMDM type 7 | 0x8807(hex), 34823(decimal) | CMDM type 7 corresponds to datamatrix size 7 (24x24 modules). CMDM size is fixed therefore bit 7 is set (0x80). Bit 4-0 has a value of 8 for mailmark C40 mode selection. |
2D CMDM type 9 | 0x8809(hex), 34825(decimal) | CMDM type 9 corresponds to datamatrix size 9 (32x32 modules). CMDM size is fixed therefore bit 7 is set (0x80). Bit 4-0 has a value of 8 for mailmark C40 mode selection. |
2D CMDM type 29 | 0x881D(hex), 34845(decimal) | CMDM type 7 corresponds to datamatrix size 29 (16x48 modules). CMDM size is fixed therefore bit 7 is set (0x80). Bit 4-0 has a value of 8 for mailmark C40 mode selection. The lowest byte has a value of 29 (1D in hex) |
2D CMDM type 12 | 0x810C(hex), 33036(decimal) | CMDM type 7 corresponds to datamatrix size 12 (44x44 modules). CMDM size is fixed therefore bit 7 is set (0x80). Note that type12 requires all data to be encoded in C40 therefore bit 4-0 has a value of 1. The value of the lowest byte is data matrix size ID, 12 (0C in hex) |