How to encode FNC1 with ZPL to GS1 QR code

2.5k views Asked by At

I am struggling to encode GS1 QR code in ZPL. The main problem is that I don't know how to encode the leading FNC1 character to indicate, that the QR code is GS1 QR code. I have tried different approaches with mixed (and strange) results. I still have a feeling that I missed something, but can't deduce what.

Disclaimer: Please don't mind the order of the GS1 Application identifiers. I needed to test the ability to terminate/separate variable length identifiers, so I scrambled it a little bit. But from the GS1 point of view - this does not affect the quality of the code.

My results so far:

^XA
^FO100,100^BQ,2,10
^FH^FDLA,01085800008580371722022210ABC_1D2112345_1D422730_1D3103000213^FS
^XZ

This seemed right. Less strict mobile app (barValid) decoded the code according to the GS1 Application identifiers (AI). Axicon 2D barcode verifier recognized the code as valid QR code. And GS1 Interpreter scanner from github ( https://github.com/mgh128/interpretGS1scan ) recognized it as valid GS1 QR code. BUT Point of sale (POS) system (Zebra MP 7000) - cash register, that is set up to accept only GS1 codes ignored the code (That is standard behaviour when it is set up to accept only GS1 codes and ignore other).

Sketchy solution - enable all types of barcodes in POS system and problem solved - thanks to the robustnes of the system, the string is recognized and decoded as if it was GS1 QR code. But it is not.

Also, more strict mobile decoders (Barcode Data Decoder / Verifier by ID automation) did not recognized this as GS1 QR code (they are right).

Second attempt:

^XA
^FO100,100^BQ,2,10
^FH^FDLA,_1D01085800008580371722022210ABC_1D2112345_1D422730_1D3103000213^FS
^XZ

Almost the same as first, but I added _1D (group separator) to the beginning of the string in hope that it will behave as FNC1. It does not. The reading results are exactly the same as with the first attempt.

Then I tried the most obvious thing - generate barcode in Zebra designer, print to .prn file and open it in text editor. To my surprise, when I set it up as GS1 QR code, in .prn file it was included as graphic element. Then I tried to create regular QR code, but with inserted FNC1 character and GS1 AI string. It worked, and the FNC1 was according to the .prn file encoded as \BC (or _BC). Upon printing and scanning the "fake/artificial" GS1 QR barcode with inserted FNC1 at the beginning of string with GS1 AIs it was decoded by all readers as valid GS1 QR, the POS read it as valid GS1 QR and even Axicon verifier was OK with it.

Then I copied the .prn file contents into online labelary zpl viewer, tried to scan it and the result was string with strange (chinese?) characters. Probably a result of wrongly set character set. Then I tried to print this .prn file directly, but the result was the same (weird character).

The GS1 FNC1 worked correctly only when I printed the label directly from Zebra designer. Upon exporting to .prn file something went wrong. But this led me to conclusion that I need to do something with character set, so I decided to use Mixed mode in ZPL for QR code. That gave me yet another interesting results.

Third attempt:

^XA
^FO100,100^BQ,2,10
^FH^FDD01018F,LA,01085800008580371722022210ABC_1D2112345_1D422730_1D3103000213^FS
^XZ

This was strange. Less strict mobile apps decoded this as GS1 QR code. POS accepted this as a valid GS1 QR code and decoded all of its contents. Also the GS1 Interpreter scanner from github recognized it as a valid GS1 QR code.

BUT Axicon 2D verifier did not recognized it as a valid barcode. Not a valid GS1 QR barcode, but not even a barcode - it did not performed any analysis, so I gues there is something terribly wrong with the code. And more strict mobile apps also did not recognized this as a valid GS1 QR code.

Then again, I tried using the _1D at the beginning of GS1 string, but with no success.

^XA
^FO100,100^BQ,2,10
^FH^FDD01018F,LA,_1D01085800008580371722022210ABC_1D2112345_1D422730_1D3103000213^FS
^XZ

The results were the same as if it was not here.

I tried using ^FH\ and substituting underscores _ with backslashes . I don't know what I hoped for, but it did nothing. I also tried using the \BC and _BC characters in the code with no success. I even tried using ~1 or \7E1 that is used in GS1 DM as FNC1, but also with no success.

As it seems to me, the only thing I need to do is to include FNC1 character at the beginning of the code, but I don't know what character / string should I use. I am not even sure if my ^FD setup is right.

Just for clarification - I used the Zebra Designer to print a valid GS1 QR code and it passed all of these "tests". It was recognized by all devices and applications. So I am sure they are set up right.

I know there are libraries for other programming languages, like bwip-js that can generate GS1 QR code in no time, but I need to do it in ZPL. Also, I know how to generate GS1 DataMatrix, but as I said, I need GS1 QR code.

This problem is realy confusing to me, because of these mixed results from different devices and applications.

*Edit

After reading through GS1 specs and QR standard I know that in order to produce GS1 QR code I have to use QR code mixed mode 0101 - FNC1 in first position. But it seems that raw ZPL is not able to produce GS1 QR code even in mixed mode. Probably an issue in ZPL to be fixed, or a feature to be added just like was GS1 rectangular DataMatrix that was added relatively recently compared to square GS1 DataMatrix. So I gues I can only wait for Zebra to impelement this feature.

*Edit #2 after accepted answer by sir Terry Burton

With the new Zebra firmware Link-OS 6.6 or highier it is possible to create GS1 QR barcodes in ZPL. ZPL code sample:

^XA
^FO100,700
^BQN,2,10
^FH\^FD>;>8010858000000000921567123^FS
^XZ

Decoding result:

GTIN             (01) 08580000000009
SERIAL           (21) 567123

There are some drawbacks to this, so read the instructions and documentation in the link in the accepted answer.

2

There are 2 answers

1
Terry Burton On BEST ANSWER

Recent ZPL version allow you to specify the "FNC1 implied in first position" mode by placing >8 at the start of the field data.

However, it doesn't currently help for generating QR Code symbols from generic GS1 Application Identifier formatted data string for the reasons described here.

1
adass On

I am not an expert in this field, however reading specs at GS1.org website may be the answer to your question.

As FNC1 has no ASCII value, when it is used as a separator character it is transmitted as (ASCII value 29). This has meant that some people, working backwards from the transmitted data, have used as the separator character and not FNC1. This is presently an error, but it makes no difference to the transmitted data when the barcode is scanned. It is also simply not possible to use a FNC1 with GS1 QR Code, as it is not part of the encodable character set.

GS1 QR Code cannot use FNC1 as this is not available as a character, so ‘%’ or ‘GS’ has to be used. (QR Code uses a Function 1 mode character in its first position to indicate that the symbol is a GS1 QR Code, but this is not the same as a Function 1 symbol character.)