Bar code Encoding of Strings

Team Name The Bar-Coders
Team Members Rob Drollinger
Mark Jennings
Ryan Stewart

The Original Question

How would the string "CSE370" be represented at the physical level in the following media? Pick one:

The Question to Answer

How would the string "CSE370" be represented at the physical level using bar codes? What encoding scheme would be most suitable for representing this string? What would the process be for building this bar code, and what considerations about this encoding process would need to be taken into account?

Background and Assumptions

The industrial use of bar codes traces back to the 1960's. The earliest implementations were used to identify rail cars. Bar codes gained wide acceptance in the 1970's when UPC bar codes started appearing on grocery items. Today, bar codes are used virtually everywhere to increase automation, improve productivity, and reduce errors. They can be used whenever there is a need to accurately identify or track an item with a machine readable tag.

Although virtually any information can be encoded, most bar codes are used to encode an item identifier that, in and of itself, provides no useful information. Instead, the identifier contains a key to an entry in a database which contains the actual information (e.g. price, manufacturer, model, etc.) about the item. Thus, bar codes are seldom useful by themselves and typically have a companion database to provide the actual information about the item. When an item is scanned, the item identifier is used to look up the item in the database which returns the useful information about the item. While there are specialty types of codes that are different (including two-dimensional bar codes that look radically different), most bar codes look something like the following:

The bar code information is encoded as a series of varying width vertical lines (called bars) and spaces between the bars. Different combinations of bars and spaces represent different characters. Different bar code specifications (also called symbologies) use different combinations; thus, bar codes produced under different specifications will vary in how easy/hard they are to print and read, the space requirements for the code (often called the bar code density), and what information can be encoded. Most bar code implementations print the bar code information in text below the bar code; however, this text is for human reading only and is not readable by the scanner.

The bar code is read by a scanning process where a scanner shines a light on the bars. The light is absorbed by the dark bars, but is reflected by the spaces between the bars. A photocell detector converts the reflected light into an electrical signal. The waveform shape of this signal can then be used to decode the bar code.

Most bar code symbologies include extra space and extra characters in addition to the actual characters encoded in the bar. Some common uses for this extra information are:

There are a variety of bar code specifications for different applications. Some encode only numeric data while others can encode alphabetic and even some punctuation characters. Some are fixed length while others allow variable lengths. Many older codes have been superseded by newer codes. Below are the most popular bar codes currently in use.

Bar code Variable Length Allowable Characters Industries in use
Older Bar codes
Code 11 Yes 0-9 AT&T pre 1990
Codabar Yes 0-9,$+.:/ Blood Banks, Cotton, Transportation
Plessey Yes 0-9,A-F Shelf Labels
MSI Yes 0-9 Shelf Labels
2 of 5 Yes 0-9 UPC Shipping Container
UPC and EAN No 0-9 Food/Discount Store Items
Newer Bar codes
Code 39 Yes 0-9,A-Z./+-%$Spc (2 character pairings for Full ASCII) LOGMARS, HIBCC, AIAG, TCIF
Code 128 Yes Full ASCII UCC_128, EAN-128
Code 93 Yes 0-9,A-Z./+-%$Spc (2 character pairings for Full ASCII) HIBCC Alternative, Canadian Postal Service

For this application (encoding the string "CSE370"), we require an encoding that provides for alphabetic characters as well as numeric characters and a variable length. We assume that we want to encode the string directly using ASCII character encoding, and not representing it in some other way. Since Code 128 provides for this, is widely used, and offers excellent density, we've concentrated on this code in the detailed discussions below, although we've used other encodings to contrast the differences.

The Result

This is the string "CSE370" encoded in Code 128 Bar code:

A string in Code 128 is constructed as follows:

We will now look at each of these components in a little more detail.

Code 128 bar code uses 4 different bar and space widths to encode the full 128 character ASCII set. The quiet zone before the beginning of the string has to be at least 10 times the width of the smallest bar used in the bar code.

The start of the actual bar code is a special start character that designates which of three different character sets to use. There are only 106 different combinations of bars and spaces by the Code 128 specifications, so Code 128 uses three different encoding sets to represent the full ASCII set plus some extra symbols. For example, Code Set C can represent all the numbers from 00 to 99, while Code Set B can do lowercase as well as capital letters.

The actual data characters themselves are represented by 3 bars and 3 spaces, in an alternating manner such that the relative widths add up to 11 (the smallest width being 1 and the largest width being 4). For example, our data has the following encoding pattern in Code Set A or B (each character starts with a bar and ends with a space):

  B S B S B S
C = 1 3 1 3 2 1
S = 2 1 3 1 1 3
E = 1 3 2 1 1 3
3 = 2 2 1 1 3 2
7 = 3 1 2 1 3 1
0 = 1 2 3 1 2 2

After the data always comes a check digit. This digit is determined by the following procedure:

In our string, this process is as follows:

Code Position Position Data Position Value Term in Sum
Start Code B 104 104
Position 1 C 35 1 x 35 = 35
Position 2 S 51 2 x 51 = 102
Position 3 E 37 3 x 37 = 111
Position 4 3 19 4 x 19 = 76
Position 5 7 23 5 x 23 = 115
Position 6 0 16 6 x 16 = 96
Total: 639
639 / 103 = 6 remainder 21

The check digit is the character with the value of 21, which is '5'.

Last in the string is the stop character, which has the regular character encoding (3 bars and 3 spaces) of 2 3 3 1 1 1, plus an extra bar at the end of width 2.

Finally, the quiet zone after the stop character is just like the initial quiet zone, also a space of at least size 10.

There are many different bar code encoding schemes out there. Just for comparison, here is the string "CSE370" represented in Code 39, or Code 3 of 9:

Code 39 with check digit:

and Code 16k:


The concept of bar coding has been extended to be used in a large variety of ways, and to represent many different kinds of data. Even after deciding that bar codes are the desired way to store some particular form of data, determining what symbology to use depends on a number of different factors. Though representing a string such as "CSE370" is most directly done using the method described above, it is very possible that a more suitable way to represent this data could be desirable for any given application.

For example, if this bar code were being encoded as a part of a campus-wide effort to catalog all courses, then it might have been more suitable to use a symbology that only allows digits, and give each course on campus a unique identifier. Then course names, along with other data about the course, could be looked up from a database instead of directly encoded in the bar code. For our purposes, however, direct encoding provided all of the necessary information, which is simply the string itself.


Title Bar code Primer - Introduction to Bar coding*
Author/Maintainer Worth Data
Web Address

Title A Web of Information About Bar code*
Author/Maintainer Russ Adams
Web Address

Title Bar code Information and Specifications
Author/Maintainer Altek Instruments, Ltd.
Web Address

Title Nick Johnson's Bar code Specifications*
Author/Maintainer Nick Johnson
Web Address

Web Address

Title The Bar code Software Center
Author/Maintainer Measurement Equipment Corporation
Web Address

* Titles in bold signify principle sources.