While the library supports decoding of the special character FNC1, it can be used to read GS1 codes. The FNC1 character is not a byte in the data stream, but rather a format character.
The specification states that the leading character FNC1 is used to identify GS1 barcodes and should be decoded as "]d2" (GS1 DataMatrix), "]C1" (GS1-128), "]e0" (GS1 DataBar Omnidirectional) or "]Q3" (GS1 QR Code). Any other FNC1 characters must be decoded as GS ASCII characters (byte value 29).
Depending on the library, the host FNC1 may be absent or decoded as GS (non-critical), or the embedded FNC1 characters may be absent (critical). The built-in FNC1 characters are used to distinguish between variable-length fields.
You can read the full specification here (pdf). The data decoding algorithm can be found in heading 7.9 Processing data from the GS1 symbol using the GS1 application identifiers (page 426).
The algorithm looks something like this:
Peek at the first character. If it is ']', If string does not start with ']C1' or ']e0' or ']d2' or ']Q3', Not a GS1 barcode. Stop. Consume the caracters. Else if it is <GS>, Consume character. Else, No symbology identifier, assume GS1. While not end of input, Read the first two digits. If they are in the table of valid codes, Look up the length of the AI-code. Read the rest of the code. Look up the length of the field. If it is variable-length, Read until the next <FNC1> or <GS>. Else, Read the rest if the field. Peek at the next character. If it is <FNC1> or <GS>, consume it. Save the read field. Else, Error: Invalid AI
The binary data in the QR code is encoded as 4-bit tokens with embedded data.
0111 -> Start Extended Channel Interpretation (ECI) Mode (special encodings). 0001, 0010, 0100, 1000 -> start numeric, alphanumeric, raw 8-bit, kanji encoded data. 0011 -> structured append (combine two or more QR Codes to one data-stream). 0101 -> FNC1 initial position. 1001 -> FNC1 other positions. 0000 -> End of stream (can be omitted if not enough space).
After the data length appears in the coding specification, followed by the actual data. The data bit values ββdepend on the encoding used. Between data blocks, you can compress FNC1 characters.
The QR Code specification ( ISO / IEC 18004 ), unfortunately, costs money (210 francs). You could find some pirated version online.
To create GS1 QR codes, you need to specify the FNC1 characters in the data. The library should either recognize the "] Q3 prefix, or GS characters, or allow you to write FNC1 tokens using another method.
If you have a way to write FNC1 characters, you can encode GS1 data as follows:
Write initial FNC1. For each field, Write the AI-code as decimal digits. Write field data. If the code is a variable-length field, If not the last field, Write FNC1 to terminate the field.
If possible, you should order such fields so that the last field is of variable length.
As Terry Burton noted in the comments; The FNC1 character in the GS1 QR code can be encoded as % in alphanumeric data and as GS in byte mode. To encode the actual percent character, you write it as %% .
To encode (01) 04912345123459 (15) 970331 (30) 128 (10) ABC123 , you first merge it into data line 01049123451234591597033130128%10ABC123 ( % indicator is an encoded character FNC1). Then this line is written as
0101 - Initial FNC1, GS1 mode indicator 0001 - QR numeric mode 0000011101 - Data length (29) <data bits for "01049123451234591597033130128"> 0010 - QR alphanumeric mode 000001001 - Data length (9) <data bits for "%10ABC123">
(example from specification ISO 18004: 2006)