Code 39
Ibadullah Safi Computer Designer in Cyber Tech IT Solutions. Live in Jalalabad, Nangarhar, First Zone.
Encoding
The * character presented below is not a true encodable character, but is the start and stop symbol for Code 39. The asymmetry of the symbol allows the reader to determine the direction of the barcode being scanned. This code is traditionally mapped to the * character in barcode fonts and will often appear with the human-readable representation alongside the barcode.

As a generality, the location of the two wide bars can be considered to encode a number between 1 and 10, and the location of the wide space (which has four possible positions) can be considered to classify the character into one of four groups (from left to right): Letters(+30) (U–Z), Digits(+0) (1–9,0), Letters(+10) (A–J), and Letters(+20) (K–T). For example, the letter P (being the 16th letter of the alphabet) has its bars aligned to represent the number 6, and the space in the far right position to select the group Letters(+20).
When represented as a digit, the number "10" is used to encode the number zero. Because there are only six letters in the Letters(+30) group (letters 30–35, or U–Z), the other four positions in this group (36–39) are used to represent three symbols (dash, period, space) as well as the start/stop character.
The two wide bars, out of five possible positions, encode a number between 1 and 10 using a two-out-of-five code with the following numeric equivalence: 1, 2, 4, 7, 0. The numbers are summed together. For example, the number 6 is encoded NWWNN, with wide bars occupying the positions for 2 and 4 (2+4=6). In the case of NNWWN which is 4+7 = 11 it is assigned to 0 for digits (+0), and 10 for the letter columns (+10 – +30). When encoding the (+10 to +30) letters the equation needs a "−1" added so 'A' is WNNNW → 1 + 10 − 1 → 10 as shown in the table.
The last four characters consist of all narrow bars and three wide spaces. There are four possible positions for the single narrow space.
This table outlines the Code 39 specification. The numeric value assigned to each character (except start/stop) is used in the checksum algorithm described below.
Bars | Spaces | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|| ||| | +0 | ||| || | +10 | |||| | | +20 | | |||| | +30 | ||||||
▮|||▮ | 1 | ▮| ||▮ | 1 | 1 | ▮|| |▮ | A | 10 | ▮||| ▮ | K | 20 | ▮ |||▮ | U | 30 |
|▮||▮ | 2 | |▮ ||▮ | 2 | 2 | |▮| |▮ | B | 11 | |▮|| ▮ | L | 21 | | ▮||▮ | V | 31 |
▮▮||| | 3 | ▮▮ ||| | 3 | 3 | ▮▮| || | C | 12 | ▮▮|| | | M | 22 | ▮ ▮||| | W | 32 |
||▮|▮ | 4 | || ▮|▮ | 4 | 4 | ||▮ |▮ | D | 13 | ||▮| ▮ | N | 23 | | |▮|▮ | X | 33 |
▮|▮|| | 5 | ▮| ▮|| | 5 | 5 | ▮|▮ || | E | 14 | ▮|▮| | | O | 24 | ▮ |▮|| | Y | 34 |
|▮▮|| | 6 | |▮ ▮|| | 6 | 6 | |▮▮ || | F | 15 | |▮▮| | | P | 25 | | ▮▮|| | Z | 35 |
|||▮▮ | 7 | || |▮▮ | 7 | 7 | ||| ▮▮ | G | 16 | |||▮ ▮ | Q | 26 | | ||▮▮ | - | 36 |
▮||▮| | 8 | ▮| |▮| | 8 | 8 | ▮|| ▮| | H | 17 | ▮||▮ | | R | 27 | ▮ ||▮| | . | 37 |
|▮|▮| | 9 | |▮ |▮| | 9 | 9 | |▮| ▮| | I | 18 | |▮|▮ | | S | 28 | | ▮|▮| | ␣ | 38 |
||▮▮| | 10 | || ▮▮| | 0 | 0 | ||▮ ▮| | J | 19 | ||▮▮ | | T | 29 | | |▮▮| | * | |
||||| | | | | || | $ | 39 | | | || | | / | 40 | | || | | | + | 41 | || | | | | % | 42 |
Characters are separated by an additional narrow space. For example, the full encoding for the single letter "A", which actually includes the start and stop characters as "*A*", is "| |▮▮|▮|| |▮| |▮▮|". The code will not be read properly without these inter-character spaces. Barcode fonts invariably include this space within the glyph for the character.
Code 39 check digit
Code 39 is sometimes used with an optional modulo 10 or 43 check digit. Using it requires this feature to be enabled in the barcode reader. The code with check digit is referred to as Code 39 mod 10 or Code 39 mod 43 respectively.
To compute this, each character is assigned a value. The assignments are listed in the table above, and almost, but not quite, systematic.
Here is how to do the checksum calculation:
- Take the value (0 through 42) of each character in the barcode excluding start and stop codes.
- Sum the values.
- Divide the result by 10 (for Mod 10 check digit) or by 43 (for Mod 43 check digit).
- The remainder is the value of the checksum character to be appended.
Full ASCII Code 39
Code 39 is restricted to 43 characters. In Full ASCII Code 39 Symbols 0-9, A-Z, ".", "-" and space are the same as their representations in Code 39. Lower case letters, additional punctuation characters and control characters are represented by sequences of two characters of Code 39.
Code Details | ||||||||||||||
Nr | Character | Encoding | Nr | Character | Encoding | Nr | Character | Encoding | Nr | Character | Encoding | |||
0 | NUL | %U | 32 | [space] | [space] | 64 | @ | %V | 96 | ` | %W | |||
1 | SOH | $A | 33 | ! | /A | 65 | A | A | 97 | a | +A | |||
2 | STX | $B | 34 | " | /B | 66 | B | B | 98 | b | +B | |||
3 | ETX | $C | 35 | # | /C | 67 | C | C | 99 | c | +C | |||
4 | EOT | $D | 36 | $ | /D | 68 | D | D | 100 | d | +D | |||
5 | ENQ | $E | 37 | % | /E | 69 | E | E | 101 | e | +E | |||
6 | ACK | $F | 38 | & | /F | 70 | F | F | 102 | f | +F | |||
7 | BEL | $G | 39 | ' | /G | 71 | G | G | 103 | g | +G | |||
8 | BS | $H | 40 | ( | /H | 72 | H | H | 104 | h | +H | |||
9 | HT | $I | 41 | ) | /I | 73 | I | I | 105 | i | +I | |||
10 | LF | $J | 42 | * | /J | 74 | J | J | 106 | j | +J | |||
11 | VT | $K | 43 | + | /K | 75 | K | K | 107 | k | +K | |||
12 | FF | $L | 44 | , | /L | 76 | L | L | 108 | l | +L | |||
13 | CR | $M | 45 | - | - | 77 | M | M | 109 | m | +M | |||
14 | SO | $N | 46 | . | . | 78 | N | N | 110 | n | +N | |||
15 | SI | $O | 47 | / | /O | 79 | O | O | 111 | o | +O | |||
16 | DLE | $P | 48 | 0 | 0 | 80 | P | P | 112 | p | +P | |||
17 | DC1 | $Q | 49 | 1 | 1 | 81 | Q | Q | 113 | q | +Q | |||
18 | DC2 | $R | 50 | 2 | 2 | 82 | R | R | 114 | r | +R | |||
19 | DC3 | $S | 51 | 3 | 3 | 83 | S | S | 115 | s | +S | |||
20 | DC4 | $T | 52 | 4 | 4 | 84 | T | T | 116 | t | +T | |||
21 | NAK | $U | 53 | 5 | 5 | 85 | U | U | 117 | u | +U | |||
22 | SYN | $V | 54 | 6 | 6 | 86 | V | V | 118 | v | +V | |||
23 | ETB | $W | 55 | 7 | 7 | 87 | W | W | 119 | w | +W | |||
24 | CAN | $X | 56 | 8 | 8 | 88 | X | X | 120 | x | +X | |||
25 | EM | $Y | 57 | 9 | 9 | 89 | Y | Y | 121 | y | +Y | |||
26 | SUB | $Z | 58 | : | /Z | 90 | Z | Z | 122 | z | +Z | |||
27 | ESC | %A | 59 | ; | %F | 91 | [ | %K | 123 | { | %P | |||
28 | FS | %B | 60 | < | %G | 92 | \ | %L | 124 | | | %Q | |||
29 | GS | %C | 61 | = | %H | 93 | ] | %M | 125 | } | %R | |||
30 | RS | %D | 62 | > | %I | 94 | ^ | %N | 126 | ~ | %S | |||
31 | US | %E | 63 | ? | %J | 95 | _ | %O | 127 | DEL | %T, %X, %Y, %Z |
Software
These free and open source software can produce Code 39 barcodes:
References
- ^ "GNU Barcode". GNU Project. 19 February 2020.