Appendix C. Version ID Parameter (updated in version 5.2)

The QRCode encoder is enhanced with the release of version 5.2. 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 version parameter.

Prior to version 5.2, the version parameter allowed is an integer between 1 and 40 which corresponds to 40 datamatrix sizes, or 0 for automatic size selection. In version 5.2, 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.

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, denotes the QRCode version number.

C.1. Modifier byte

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 version 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. Some applications require the entire data to be encoded under the same mode. For those applications, choose a value that fits the requirement.

  • 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, and si compatible with previous releases.

  • Value 1 indicates that encoder must use the same mode througout; however, the mode is selected based on data entered.

  • Value 2 indicates that encoder must use numeric mode throughout the symbol.

  • Value 3 indicates that encoder must use alphanumeric mode throughout the symbol.

  • Value 4 indicates that encoder must use byte mode throughout the symbol.

C.2. Version byte

The value of this byte corresponds to QRCode version. A qrcode symbol may have 40 different sizes, numbered from 1 to 40.

C.3. Example

The QRcode writer in zxing library (as of v3.3) uses a single mode for the whole symbol. In order to achieve the same result, the modifier byte should have a value of 1 (single mode, auto mode selection). If the version byte is 17 (0x11), then the value to Version parameter should be 0x0100 | 0x11 = 0x0111 = 273.