How to Choose Barcode Symbology

For one project I needed to select proper barcode symbology (way of encoding). Requirements were clear: variable length (that excludes EAN/UPC subset), some form of check-sum and it needs to work with standard (aka cheap) equipment. That left me with few candidates which I will try to describe.

2 of 5

This symbology is well supported since it is quite old (circa 1960) and it is used within industry. It is numeric only code and there is optional support for check-sum (modulo 10) digit, but that digit needs to be encoded and decoded by software (this may be a problem if you have some devices which are not under your control). Problem is also in width of code since this one encodes data only in bars which makes for a lot of wasted space. It's low density could be a problem if you are "space challenged".

To overcome excessive width of standard 2 of 5, somebody though of encoding data in both bars and spaces. That effectively made code twice as dense as standard one (or twice as short) for same amount of data but support is only available for even number of digits. Everything else said for standard version is same for this one.

Codabar (NW-7)

Used mostly within blood banks this symbology allows for numbers with limited number of symbols (- $ : / . +). Since it is self-checking there is no additional check-sum needed but one can always use a software one. Code can start and end in four different ways (usually called A B C D) so there is possibility of differentiating code on that base also (but be aware of lock-in since no other code has that option). Since characters are separated with space code is not among shortest.

Code 3 of 9 (Code 39)

This is alphanumeric code and enables encoding numbers, characters (big case only) and some symbols (space - . $ / + % *). It is self checking so check-sum is not necessary but there is defined way of doing it if more security is needed. There is also possibility of concatenating multiple barcodes together but that possibility is rarely used (just don't start your code with space). There is also extended variant that can encode whole ASCII (0-127) range.

Code 128

This symbology is three in one deal. Three different encodings not only allow for full ASCII (0-127) to be encoded but there is also special double density mode which allows it to encode numeric only data in half the width. Check-sum (modulo 103) is mandatory part of encoding so no additional support is needed within software. Since symbols are also self-checking this gives very high confidence in reading. There were small problems with reading Code 128 with old barcode readers but everything that is recent on market supports it. Since there are three different ways of encoding data (and switching between them within) writing optimal encoder is not an easy task.

Conclusion

At the end, I selected Code 128. Not only that it gives highest possible level of security but it also has shortest code (with numeric data at double density). Slightly complex encoding was just another challenge that needed overcoming. C# source code is available.

Useful pages

Here are few pages where you can find more information - enough to write your own encoder.

2 thoughts to “How to Choose Barcode Symbology”

  1. The most inexpensive way to print a barcode is to use a barcode font. You use your word processor and existing printer. Just type in the number you want to barcode, then change the font from the default font to the barcode font. You can print out using sheets of Avery address labels.

  2. This is true for simpler barcode symbologies. <BR/>More complex (and more secure – checksum wise) ones like Code 128 cannot be encoded as simple.<BR/>You could use specialized font for them but then you need to do additional encoding.<BR/>One other issue with which I had problems with (yes, I did use barcode fonts before – I even made one) is printing on low-dpi devices. Most of printers smooth fonts and that could prove to be a problem.

Leave a Reply

Your email address will not be published. Required fields are marked *