Keith acquired the Code 3 of 9 algorithm from Ed Rickman at the Research Triangle Institute in 1991 while working for Computer Sciences Corporation under contract to the U.S. EPA on a project to redesign the database for the Radon Measurement Proficiency (RMP) Program. CSC and EPA used it to bar-code mailing labels for participants 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.
| 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 characters.) If you like mathematical and logical puzzles, and you don’t already know the encoding algorithm for postal bar codes, try figuring it out just by looking at several examples.
| 4 Nov 2006 Keith |