Chapter 2. Overview

This chapter briefly reviews the symbologies (a.k.a. barcode formats) supported by QR Code Fonts & Encoder 5. QRCode Fonts & Encoder 5 supports normal QR Code, Micro QR Code and HIBC QR Code (which is based on normal QRcode).

2.1. What is QR Code?

QR CodeMicro QR Code

QR Code is capable of handling all types of data, such as numeric and alphabetic characters, Kanji, binary bytes and control codes. Up to 7,089 digits can be encoded in one symbol.

QR Code has undergone two major revisions - Model 1 and Model 2. It is generally believed that the two models are not compatible with each other. The ISO/IEC 18004:2006 defines Model 2, often referred as QR Code 2005.

This software produces QR Code symbols compliant with Model 2 only.

QR Code supports several advanced features not present in many other barcode formats, such as Extended Channel Interpretation (ECI), FNC1 and Structural Append (SA). The advanced features require special input format. For more information, see Section 2.2.4, “Structural Append (SA)”.

HIBC QRCode is a variant of QR Code. It uses QR Code to encode HIBC LIC. When this option is specified, our program automatically adds + sign at the beginning and appends a checksum digit at the end, then encodes them as a whole.

The Micro QR Code format (also specified in this International Standard), is a variant of QR Code 2005 with a reduced number of overhead modules and a restricted range of sizes, which enables small to moderate amounts of data to be represented in a small symbol, particularly suited to direct marking on parts and components, and to applications where the space available for the symbol is severely restricted. Micro QR is capable of encoding up to 35 digits, 21 alphanumeric characters, 15 bytes or 9 kanji characters.

2.1.1. Encoding Character Set

QR Code is capable of encoding four types of data, as listed below. Note that the interpretation of byte characters is subject to the ECI, which is assumed to be ISO8859-1 if no ECI is defined in the symbol.

  • Numeric characters: 0-9.

  • Alphanumeric characters: digits 0-9, all upper case letters (A-z) and 9 punctuation symbols (space, $, %, *, +, -, ., : and /).

  • Byte characters: single byte (ASCII value 0-255).

  • Kanji characters. A Kanji character consists of two bytes and has a value either between 0x8140 and 0x9ffc, or between 0xe040 and 0xebbf. In the software, they must be enclosed in a special format block called Kanji block. Read further for more information on Kanji block.

QR Code defines several encoding modes, with the numeric set the most efficient and the Kanji set the least. Internally, the encoder switches the modes automatically based on the nature of the data, with the goal of minimizing the symbol size required. The algorithm produces the optimal results in most cases.

When space is a concern, it is desirable to adjust the character set of data encoded so that they can be more efficiently encoded. For example, the alphanumeric character set in QR Code does not include lower case letters. If the string encoded is case insensitive, it reduces space requirement by converting all letters upper case.

QR Code also defines several advanced features that can only be encoded with escaped format, referred as tilde codes throughout the manual. These advanced features include:

  • ECI. ECI was proposed by AIM to give a unified interpretation to the byte data encoded in a barcode symbol, thus allowing different character set of data to be mixed in a symbol.

  • Structural Append. Structural Append allows data to be split into multiple symbols. Beside to the data, those symbols encode additional information such as sequence number, total number of symbols, and parity value. A capable reader is able to read them randomly and put the data together.

  • FNC1. GS1 uses this special character to indicate that a GS1-compatible data encoded in the symbol.

2.1.2. Options

Three options affect the final shape of the symbol generated:

Symbol Version

QR Code has a total of 40 different sizes. Each size is referred as Version, ranged from 1 to 40. Version 1 consists of 21 x 21 modules, and version 40 consists of 177 x 177 modules. Each higher version number comprises 4 additional modules per side. Each QR Code symbol version has the maximum data capacity according to the amount of data, character type and error correction level.

There are four versions available in Micro QR - M1, M2, M3 and M4. This software allows version request greater than 4 in Micro QR; however, only the maximum version allowed is realized.

By specifying 0 as the version, the software selects the minimum version that fit the data encoded. Furthermore, if the version requested is too small, the software also increases it automatically to fit the data encoded.

Note: in version 5.2, the Version parameter is enhanced to include a modifier byte to fine tune encoder behavior. See Appendix C, Version ID Parameter (updated in version 5.2) for more information.

Error Correction Level

QR Code has error correction capability to restore data if the code is dirty or damaged. Four error correction levels are available for users to choose according to the operating environment. Raising this level improves error correction capability but also increases the amount of data QR Code size.

To select error correction level, various factors such as the operating environment and QR Code size need to be considered. Level Q or H may be selected for factory environment where QR Code gets dirty, whereas Level L may be selected for clean environment with the large amount of data.

The recovery capacity of the four levels are approximately 7%, 15%, 25% and 30%.

In case of Micro QR, not all error correction level is available to all versions. For example, level Q is only available on version M4. In this case, our software bumps the version automatically to accommodate the error correction level.

Data Masking

The read reliability of a QR Code symbol can be improved through a method called data masking. Seven bit patterns (000 - 111) can be used to mask a symbol. Our software provides another value, -1, which selects the mask pattern that produces the best result.

2.2. Input Format

Note

The input format specified in this section applies on normal QR code and Micro QR only. HIBC QR Code only accepts the characters defined in HIBC character set.

QR Code supports several advanced features such as ECI and Structural Append. Those features can only achieved using tilde codes outlined in this section.

~dnnn

When nnn corresponds to a numeric value between 0 and 255, the tilde code sequence represents a character with value equal to nnn. For example, ~d032 represents a space character.

~~

Represents a tilde (~) character.

~1

Represents a FNC1 character, first position. Note: this feature is not available in Micro QR.

~2

Indicates that a structural append control block follows. Must appear at the beginning of the input. Note: this feature is not available in Micro QR.

~3

Represents a FNC1 character, second position. See notes below for more information. In order for the program to find the AI, the AI must follow immediately and placed inside a pair of square brackets. The standard implies that the AI must be a numeric value between 0 and 255. For example ~3[37]. Note: this feature is not available in Micro QR.

~4

Starts a Kanji block. The Kanji characters must be enclosed in brackets and follow immediately.

~50

Starts a center overlay block. The center overlay feature allows a pattern to be placed on the center of the QR code.

~7, ~8 and ~9

Indicates the start of an ECI block. This escape sequence must be followed by exact 6 digits, which corresponds to the ECI value. See Section 2.2.3, “Extended Channel Interpretation (ECI)” for more information.

~X

Represents a character value from 0 to 26. Replace the X like in the following example ~@ means character ASCII 0, ~A means character 1, ~B means character 2, ~C means character 3 ...

Note that ~dnnn sequence is allowed to appear within a Kanji block, but not in other blocks such as Structural Append. For example, ~2[1][6] is a valid SA block, but ~2[1][~d54] is not. ~dnnn should not be used in ECI block either.

2.2.1. Center Overlay Block

The Center Overlay Block feature, also referred as feature 50 in this manual, allows user to specify a bit pattern block that is overlaid on the center of the QR Code. This feature is required to implement QR Code for Swiss payment, where a Swiss logo is required to overlay on the center of the barcode.

Because QR Code has error correction capability, overlaying a small image won't affect the reading. However, care must be taken to avoid situations that the image is too big to cause the whole barcode unreadable.

The following are the two examples of center overlay block. In the first one, the overlaid bit pattern is expressed as rows, cols and pattern. In the second one, :swiss7 indicates to overlay 7 mm x 7mm swiss logo when the overall symbol size is 46mm x 46 mm (the size required by Swiss payment standard). Both starts with tilde code 50, so this feature is also referred as Feature 50.

~50[7,7,007c6c446c7c]

~50[:swiss7]

For more information about Center Overlay Block, see Appendix E, Center Overlay (Feature 50) Support.

2.2.2. Kanji Block

QRCode can encode Kanji text natively. A Kanji character consists of two bytes and has a value either between 0x8140 and 0x9ffc, or between 0xe040 and 0xebbf. Kanji characters are inputted using Kanji block, which starts with ~4 following by the byte values of kanji characters enclosed in square brackets. Byte values can be escaped using ~dnnn format. For example, the following code is the input for text

89~4[~d147~d250~d150~d123]

The Kanji characters have hex values 0x93fa and 0x967b - whose corresponding decimal values are 147, 250, 150 and 123.

2.2.3. Extended Channel Interpretation (ECI)

ECI was introduced to allow mixed character sets in a QRCode symbol, and to enable different interpretations on the output data stream.

An ECI can be any number between 000000 and 999999. The tilde code sequence ~7nnnnnn is used to enter an ECI value. The code sequence can appear at any places of the input, but there must be exact 6 digits following ~7. For example to start an interpretation of 10, enter ~7000010.

In addition to ~7 (ECI basic), ~8 and ~9 can be used to represent Nesting-Begin and Nesting-End. The Nesting-Begin ECI does not turn off the current ECI in force until Nesting-End is encountered at the current nesting level. This allows multiple ECIs (for example, Greek language plus encryption) effective in a data segment.

The table below lists common ECI values and their corresponding character encoding. Note that some character encodings may have multiple ECI values. For example, you can use either 1 or 3 for ISO8859-1 encoding.

Table 2.1. List of common ECI values

Character encodingECI value
CP437 (DOS)0, 2
ISO8859-11, 3
ISO8859-24
ISO8859-35
ISO8859-46
ISO8859-57
ISO8859-68
ISO8859-79
ISO8859-810
ISO8859-911
ISO8859-1012
ISO8859-1113
ISO8859-1214
ISO8859-1315
ISO8859-1416
ISO8859-1517
ISO8859-1618
Shift_JIS20
Windows-125021
Windows-125122
Windows-125223
Windows-125624
UTF-16BE25
UTF-826
US-ASCII27, 170
Big528
GB231229
EUC-KR30

Default ECI

In 2005 ISO standard, the default ECI is ISO8859-1. In the 1997 AIM standard and 2000 ISO standard, the default ECI corresponds to the JIS8/ShiftJIS character set.

ECI and Structural Append

The 2005 standard makes it necessary to add ECI values after Structural Append for each ECI in force in individual symbols. This implies that ECI in force does not cross symbol boundary. This behavior is departed from the 1997 AIM standard.

2.2.4. Structural Append (SA)

The structural append feature allows up to 16 symbols in a structure. A capable reader buffers the contents of each symbol until all symbols are read.

To encode structural append, supply the three required fields for each symbol:

  • Symbol Position (SP). The symbol position is 1-based index which identifies the position of this particular symbol in the group. Can be any number between 1 and 16.

  • Total Number of Symbols (TS). This value indicates the number of total symbols. Can be any number between 1 and 16. The value should be consistent among all symbols in the group.

  • Parity (P). This value must remain the same across all symbols in the group. This value is derived from the full input data. The font encoder DLL and Crystal Reports UFL provide functions to calculate the parity value. See Appendix B, How to Calculate Parity Value in Structural Append for details. The Parity Calculator in the GUI encoder also can be used to calculate the parity value.

The tilde code sequence is expressed in the following format:

~2[SI][TS,P]

For example, tilde code sequence ~2[1][6,89] indicates that the current symbol belongs to a group that has 6 symbols in total. The parity value for input is 89.

The structural append block must appear at the beginning of the input.

Structural append is not supported in Micro QR code.

2.2.5. FNC1 (First Position)

FNC1 (first position) is used when encoding GS1 structural data (GS1-128) in QR Code symbols. The leading FNC1 symbol is required to indicate the data followed is a GS1 structured data.

When encoding GS1 structured data, it is user's responsibility to ensure that the data supplied is correct (data length and checksum), and a separator is present after a variable length data item. QRCode standard requires % character to be used as separator, instead the FNC1 character as in the case of Code 128.

For example, to encode GS1 structural data (01)04912345123459(15)970331(30)128(10)ABC123, which denotes GT IN number 04912345123459, Sell By date 97/03/31, Quantity 128 and Lot number ABC123, the input should be:

~101049123451234591597033130128%10ABC123

FNC1 First Position is not supported in Micro QR code.

2.2.6. FNC1 (Second Position)

FNC1 (second position) is an AIM extension to encode structural data similar to GS1. The encoder needs to know the AI in order to create an encoding. Therefore, it is required to put AI in brackets immediately after tilde code ~3.

FNC1 Second Position is not supported in Micro QR code.

2.2.7. Unicode String Support

QR Code 2005 does not support unicode natively. The default character set is ISO8859-1. Theoratically the support could become available using ECI; however most scanners and applications do not have ECI support builtin.

Recently in mobile industry the trend is to use UTF8 to encode Unicode string into QR Code. Such feature requires support of the reader. We decided to add Unicode support in a way compliant with Android/IPhone barcode reader. Therefore, you need to have compliant reader in order to decode properly.

This feature is added in 5.1, released in May 2012. Enhancement is made for components that take UTF16 string input, such as QR Code ActiveX control and Word Add In. If all characters in the input string falls into ISO8859-1, the resulted barcode remains the same. Otherwise the input is converted to UTF8 with BOM first, and then encoded. In Font encoder DLL, additional function QRCodeEncode2W is added to perform such operation. More information is available at Appendix D, Unicode String Encode Support.

Note

UTF-8 encoded QR code gains popularity as it encoded the full Unicode character set without using ECI. Many scanners can be configured to read in UTF-8 mode, and mobile phones read them universally due to open source zxing library. Started from version 5.3.3 (release in March 2022), unicode APIs always convert unicode strings to UTF-8. This change may break existing applications, see more information at Appendix D, Unicode String Encode Support.

2.3. Working with QRCode Fonts & Encoder 5

This software provided three methods to integrate QRCode printing functionality to various applications - font, image and ActiveX. Depending on your working environment, you will find the best approach that fits your need.

2.3.1. Font-Based

Creating barcodes using fonts involves two distinct processes: encoding and rendering. Rendering is to choose the appropriate font and font size and format the encoding results. Encoding is to convert the data into a special string, refereed as Barcode String, which becomes a barcode after being formatted with the font.

Note

In almost all circumstances, you cannot just type your number and format with a barcode font to create a valid barcode. You must generate the barcode string first, and format the barcode string with the font.

The font-based approach is easy to understand, and in some occasions the only way to add barcode printing functionality, such as in Crystal Reports.

The drawing below illustrates how you create a QR code using font-based approach. You first create the barcode string (which is an array of text lines). Format the barcode string with MRV QRCode font you get the barcode.

The font characteristics are listed as below:

Table 2.2. QRCode Font Characteristics

FilenameTypefaceModule With (under 6 points)
mrvqrcode.ttfMRV QRCode20 mils (0.5mm)

2.3.1.1. Encoding

To create a valid barcode, you need to call an encoder to get a special string, and format this string with our QRCode font. To get this string, you need to call an encoder - you can run QRCode Encoder GUI, and obtain the result from this GUI program. Or if you need to bulk generate the results, using the programming interface exposed from the encoder DLL.

QRCode Encoder GUI

This GUI program allows you to quickly create barcode string and transfer it to other programs. You are able to enter the data encoded, and create the barcode on the fly. For more information, see Chapter 3, Using Encoder GUI.

MoroviaQRCodeFontEncoder5.dll

This DLL is a standard Windows DLL that can be called by many programming environments, including Microsoft Office, C++, FoxPro and .Net. Most programming environments support Windows DLL directly. We provide a VBA module and a C# class that wrap around the DLL functionality.

cruflQRCode5.dll

This DLL is a crystal reports extension DLL which adds the encoding functionality to Crystal Reports. For more information on using it in Crystal Reports, see Chapter 5, Adding QR Code Symbols to Crystal Reports.

Note

Barcode string support is provided through MoroviaQRCodeFontEncoder5.dll and cruflQRCode5.dll(which is a COM component). If your programming environment only support calling COM objects, such as PHP and VBScript, refer to KB10621 on how to get bar code string through COM.

2.3.2. Image File Based

You can export barcodes as standard image files to be consumed in other word processing and imaging programs. The QRCode Encoder GUI supports exporting images in four formats via a GUI interface. The Encoder DLL and QRCode ActiveX Control also provide programming interfaces to export images in those formats:

  • PNG (Portable Network Graphics)

  • BMP (Windows Bitmap File)

  • EMF (Ehanced Meta File)

  • SVG (Scalable Vector Graphics)

  • EPS (Encapsulated PostScript)

Special attention should be paid when the target printer has low resolution, such as a thermal printer or fax machine. When generating vector graphics files, the software allows you to specify target dpi which you should set to the one that matches your printer. It is generally not recommended to scale the image down or up when working with low-resolution printers.

2.3.3. ActiveX Control

For environments that support ActiveX Controls (also called OLE controls), you can insert the QRCode ActiveX Control into documents, spreadsheets, or invokes the control at the background in your program. With ActiveX Control you are able to change the barcode image by editing its properties.

Using ActiveX Control in Microsoft Office programs is straightforward. Programming knowledge is required in order to integrate the control with your custom programs.