Bar Codes

Code 3 of 9 Bar Codes

Keith acquired the Code 3 of 9 algorithm from Ed Rickman at the Research Triangle Institute in 1991 while work­ing for Com­puter Sciences Corpora­tion under con­tract to the U.S. EPA on a proj­ect to re­design the data­base for the Radon Meas­ure­ment Pro­fi­ciency (RMP) Pro­gram. CSC and EPA used it to bar-code mail­ing labels for partici­pants in the program.

The source code was developed as C++, but it is really just plain old C. There’s nothing object-oriented about it.

Feel free to take the C/C++ code and modify it to suit your needs. That’s what Keith did with the Pascal code that Ed provided.

Note: You can print bar codes, including Code 3 of 9 bar codes, just by acquiring the right fonts for your com­puter and printer. Don’t waste time pro­gram­ming your own bar codes if a new font will meet your needs.
File Description
barcode.zip Zipped file containing the source code
code39.h Header file for the Code 3 of 9 functions
text39.h Header file for digitized text functions
hpbar.h Header file for printing bar codes on a PCL® printer
code39.cpp C++ source for encoding text strings as Code 3 of 9 bar codes
text39.cpp C++ source code for encoding text strings in a bit-mapped font, which can be combined with a Code 3 of 9 bar code (Keith added this feature)
hpbar.cpp C++ source code for displaying bar codes (with text) on a PCL printer

By the way, the original postal bar codes are even simpler than Code39. (There are only 10 char­acters.) If you like math­ematical and logical puzzles, and you don’t already know the encoding algo­rithm for postal bar codes, try figur­ing it out just by look­ing at sev­eral examples.