The Rules of Encoding

By Ken Traub

Here's how to ensure RFID tags and bar codes coexist happily.

  • TAGS

Some applications identify an asset, product or other item with both an RFID tag and a bar code. For this to work, the same unique identifier must be encoded to both the tag and the bar code. But there are different rules for encoding data to tags and bar codes. Here's what you need to know to program your software to encode the same data to tags and bar codes.

Let's consider the common case of a product that carries a Global Trade Item Number (GTIN) and a unique serial number. The GTIN is a 14-digit number that looks like this: 00614141123452, and the serial number is a few digits, such as 5678.

A bar code holds a single string of characters. To encode a GTIN and a serial number, there has to be a way to separate the GTIN from the serial number—and to distinguish both from other data a bar code might contain. The industry standard GS1 General Specifications explains it: The GTIN is preceded by the digits "01," indicating that the next 14 characters are a GTIN, and the serial number is preceded by "21." The GTIN-serial combination is preceded by the Function Code One (FNC1) symbol, which means the remainder of the bar code is encoded according to GS1 standards. Putting that all together, the contents of the bar code become FNC1 0100614141123452215678.

An RFID tag does not hold any characters. Instead, it contains 96 bits of binary data. A common mistake is to program the bar-code data into the RFID tag, character by character, but that is not what applications reading an RFID tag expect to see. The correct way to program a tag is to use the binary-oriented GS1 EPC Tag Data Standard. Generally, this requires specialized software that knows the encoding rules or writing your own software following the rules in the Tag Data Standard. (My online tool lets you try out the encoding interactively.)

In our example, the GTIN and serial number would be encoded into the following 96 bits: 3034257BF40C0E400000162E (a hexadecimal representation of binary data in which each character corresponds to four binary bits). Keep in mind that, just as you can't program bar-code characters into the RFID tag, you can't put a hexadecimal string into a bar code (another common mistake).

If you're printing RFID labels that include a bar code, look for label-writing software that has built-in support for both the RFID and bar-code standards. In other instances, you will need to encode the tag and bar code separately.

A business application should work with the GTIN and serial number regardless of whether a bar code or RFID tag was read. But first, the bar-code string and the RFID binary data must be decoded. For more information about how to use RFID and bar codes for the same application, see the GS1 Bar Code/­RFID Interoperability Guideline.

Ken Traub is the founder of Ken Traub Consulting, a Mass.-based firm providing services to com­panies that rely on advanced software technology to run their businesses. Send your software questions to