Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Code 39
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Variable length, discrete barcode symbology}} '''Code 39''' (also known as '''Alpha39''', '''Code 3 of 9''', '''Code 3/9''', '''Type 39''', '''USS Code 39''', or '''USD-3''') is a variable length, discrete [[barcode]] symbology defined in [[ISO]]/[[International Electrotechnical Commission|IEC]] 16388:2023. The Code 39 specification defines 43 characters, consisting of uppercase letters (A through Z), numeric digits (0 through 9) and a number of special characters (-, ., $, /, +, %, and [[space (punctuation)|space]]). An additional character (denoted '*') is used for both start and stop delimiters. Each character is composed of nine elements: five bars and four spaces. Three of the nine elements in each character are wide (binary value 1), and six elements are narrow (binary value 0). The barcode scheme does not contain a check digit (in contrast to—for instance—[[Code 128]]), but it can be considered self-checking on the grounds that a single erroneously interpreted bar cannot generate another valid character. Possibly the most serious drawback of Code 39 is its low data density: It requires more space to encode data in Code 39 than, for example, in Code 128. This means that very small goods cannot be labeled with a Code 39 based barcode. However, Code 39 is still used by some postal services (although the [[Universal Postal Union]] recommends using Code 128 in all cases<ref>As one example of an international standard, see {{cite web |title=Identification of postal items – 13-character identifier |date=17 October 2017 |url=https://www.upu.int/UPU/media/upu/files/postalSolutions/programmesAndServices/standards/S10-12.pdf|publisher=[[Universal Postal Union]] }}</ref>), and can be decoded with virtually any [[barcode reader]]. One advantage of Code 39 is that since there is no need to generate a check digit, it can easily be integrated into an existing printing system by adding a barcode font to the system or printer and then printing the raw data in that font. Code 39 was developed by [[David Allais|Dr. David Allais]] and Ray Stevens of [[Intermec]] in 1974. Their original design included two wide bars and one wide space in each character, resulting in 40 possible characters. Setting aside one of these characters as a start and stop pattern left 39 characters, which was the origin of the name Code 39.<ref>{{cite journal |author=Allais, D. C. |year=2006 |title=AIDC Memoirs |url=http://aidc100.org/files/Allais-_David_Memoirs.pdf |access-date=2010-06-02 |archive-url=https://web.archive.org/web/20130126112426/http://aidc100.org/files/Allais-_David_Memoirs.pdf |archive-date=2013-01-26 |url-status=dead }}</ref> Four punctuation characters were later added, using no wide bars and three wide spaces, expanding the character set to 43 characters. Code 39 was later standardised as [[ANSI]] MH 10.8 M-1983 and MIL-STD-1189.<ref>{{cite web |url=https://apps.dtic.mil/sti/tr/pdf/ADA473534.pdf |title=MIL-STD-1189 Standard Department of Defense Barcode Symbology |date=1989-08-10 |accessdate=2024-06-30 |archive-url=https://web.archive.org/web/20240701064338/https://apps.dtic.mil/sti/tr/pdf/ADA473534.pdf |archive-date=2024-07-01 |url-status=live }}</ref> MIL-STD-1189 has been cancelled and replaced by ANSI/AIM BC1/1995, Uniform Symbology Specification — Code 39.<ref>{{cite web |url=http://www.dscp.dla.mil/subs/support/specs/crds/milstan.asp |title=Adoption Notice: AIM/BC1 Uniform Symbology Specification |date=1997-06-19 |accessdate=2011-04-06 |archiveurl=https://web.archive.org/web/20110927231714/http://www.dscp.dla.mil/subs/support/specs/crds/milstan.asp |archivedate=2011-09-27 |url-status=dead }}</ref> == 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 [[font]]s and will often appear with the human-readable representation alongside the barcode. [[File:Free 3 of 9 (Code 39 barcode).svg|thumb|Code 39 characters]] 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 {{nobr|1=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. {| class="wikitable" |+ Code 39 characters (and checksum values) !rowspan=2 colspan=2| Bars ||colspan=12| Spaces |- !colspan=2| {{pipe}}{{pipe}} {{pipe}}{{pipe}}{{pipe}} || +0 ||colspan=2| {{pipe}}{{pipe}}{{pipe}} {{pipe}}{{pipe}} || +10 ||colspan=2| {{pipe}}{{pipe}}{{pipe}}{{pipe}} {{pipe}} ||+20 ||colspan=2| {{pipe}} {{pipe}}{{pipe}}{{pipe}}{{pipe}} || +30 |- ! ▮{{pipe}}{{pipe}}{{pipe}}▮ || 1 | ▮{{pipe}} {{pipe}}{{pipe}}▮ || 1 || 1 || ▮{{pipe}}{{pipe}} {{pipe}}▮ || A || 10 || ▮{{pipe}}{{pipe}}{{pipe}} ▮ || K || 20 || ▮ {{pipe}}{{pipe}}{{pipe}}▮ || U || 30 |- ! {{pipe}}▮{{pipe}}{{pipe}}▮ || 2 | {{pipe}}▮ {{pipe}}{{pipe}}▮ || 2 || 2 || {{pipe}}▮{{pipe}} {{pipe}}▮ || B || 11 || {{pipe}}▮{{pipe}}{{pipe}} ▮ || L || 21 || {{pipe}} ▮{{pipe}}{{pipe}}▮ || V || 31 |- ! ▮▮{{pipe}}{{pipe}}{{pipe}} || 3 | ▮▮ {{pipe}}{{pipe}}{{pipe}} || 3 || 3 || ▮▮{{pipe}} {{pipe}}{{pipe}} || C || 12 || ▮▮{{pipe}}{{pipe}} {{pipe}} || M || 22 || ▮ ▮{{pipe}}{{pipe}}{{pipe}} || W || 32 |- ! {{pipe}}{{pipe}}▮{{pipe}}▮ || 4 | {{pipe}}{{pipe}} ▮{{pipe}}▮ || 4 || 4 || {{pipe}}{{pipe}}▮ {{pipe}}▮ || D || 13 || {{pipe}}{{pipe}}▮{{pipe}} ▮ || N || 23 || {{pipe}} {{pipe}}▮{{pipe}}▮ || X || 33 |- ! ▮{{pipe}}▮{{pipe}}{{pipe}} || 5 | ▮{{pipe}} ▮{{pipe}}{{pipe}} || 5 || 5 || ▮{{pipe}}▮ {{pipe}}{{pipe}} || E || 14 || ▮{{pipe}}▮{{pipe}} {{pipe}} || O || 24 || ▮ {{pipe}}▮{{pipe}}{{pipe}} || Y || 34 |- ! {{pipe}}▮▮{{pipe}}{{pipe}} || 6 | {{pipe}}▮ ▮{{pipe}}{{pipe}} || 6 || 6 || {{pipe}}▮▮ {{pipe}}{{pipe}} || F || 15 || {{pipe}}▮▮{{pipe}} {{pipe}} || P || 25 || {{pipe}} ▮▮{{pipe}}{{pipe}} || Z || 35 |- ! {{pipe}}{{pipe}}{{pipe}}▮▮ || 7 | {{pipe}}{{pipe}} {{pipe}}▮▮ || 7 || 7 || {{pipe}}{{pipe}}{{pipe}} ▮▮ || G || 16 || {{pipe}}{{pipe}}{{pipe}}▮ ▮ || Q || 26 || {{pipe}} {{pipe}}{{pipe}}▮▮ || - || 36 |- ! ▮{{pipe}}{{pipe}}▮{{pipe}} || 8 | ▮{{pipe}} {{pipe}}▮{{pipe}} || 8 || 8 || ▮{{pipe}}{{pipe}} ▮{{pipe}} || H || 17 || ▮{{pipe}}{{pipe}}▮ {{pipe}} || R || 27 || ▮ {{pipe}}{{pipe}}▮{{pipe}} || . || 37 |- ! {{pipe}}▮{{pipe}}▮{{pipe}} || 9 | {{pipe}}▮ {{pipe}}▮{{pipe}} || 9 || 9 || {{pipe}}▮{{pipe}} ▮{{pipe}} || I || 18 || {{pipe}}▮{{pipe}}▮ {{pipe}} || S || 28 || {{pipe}} ▮{{pipe}}▮{{pipe}} || [[space (punctuation)|␣]] || 38 |- ! {{pipe}}{{pipe}}▮▮{{pipe}} || 10 | {{pipe}}{{pipe}} ▮▮{{pipe}} || 0 || 0 || {{pipe}}{{pipe}}▮ ▮{{pipe}} || J || 19 || {{pipe}}{{pipe}}▮▮ {{pipe}} || T || 29 || {{pipe}} {{pipe}}▮▮{{pipe}} || * || |- !colspan=14| |- ! {{pipe}}{{pipe}}{{pipe}}{{pipe}}{{pipe}} || | {{pipe}} {{pipe}} {{pipe}} {{pipe}}{{pipe}} || $ || 39 || {{pipe}} {{pipe}} {{pipe}}{{pipe}} {{pipe}} || / || 40 || {{pipe}} {{pipe}}{{pipe}} {{pipe}} {{pipe}} || + || 41 || {{pipe}}{{pipe}} {{pipe}} {{pipe}} {{pipe}} || % || 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 {{nobreak |"{{pipe}} {{pipe}}▮▮{{pipe}}▮{{pipe}}{{pipe}} {{pipe}}▮{{pipe}} {{pipe}}▮▮{{pipe}}"}}. 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 [[checksum|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. To perform 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. {| |- style="background:#C0C0C0" | style="text-align:center" colspan="15" | '''Code Details''' |- style="background:#C0C0C0" | '''Nr''' || '''Character''' || '''Encoding''' | style="background:#FFFFFF" | | '''Nr''' || '''Character''' || '''Encoding''' | style="background:#FFFFFF" | | '''Nr''' || '''Character''' || '''Encoding''' | style="background:#FFFFFF" | | '''Nr''' || '''Character''' || '''Encoding''' |- style="background:#F0F0F0" | 0 || NUL ||%U | style="background:#FFFFFF" | | 32 || [space] || [space] | style="background:#FFFFFF" | | 64 || @ ||%V | style="background:#FFFFFF" | | 96 || ` ||%W |- style="background:#F0F0F0" | 1 || SOH || $A | style="background:#FFFFFF" | | 33 || ! || /A | style="background:#FFFFFF" | | 65 || A || A | style="background:#FFFFFF" | | 97 || a || +A |- style="background:#F0F0F0" | 2 || STX || $B | style="background:#FFFFFF" | | 34 || " || /B | style="background:#FFFFFF" | | 66 || B || B | style="background:#FFFFFF" | | 98 || b || +B |- style="background:#F0F0F0" | 3 || ETX || $C | style="background:#FFFFFF" | | 35 || # || /C | style="background:#FFFFFF" | | 67 || C || C | style="background:#FFFFFF" | | 99 || c || +C |- style="background:#F0F0F0" | 4 || EOT || $D | style="background:#FFFFFF" | | 36 || $ || /D | style="background:#FFFFFF" | | 68 || D || D | style="background:#FFFFFF" | | 100 || d || +D |- style="background:#F0F0F0" | 5 || ENQ || $E | style="background:#FFFFFF" | | 37 ||% || /E | style="background:#FFFFFF" | | 69 || E || E | style="background:#FFFFFF" | | 101 || e || +E |- style="background:#F0F0F0" | 6 || ACK || $F | style="background:#FFFFFF" | | 38 || & || /F | style="background:#FFFFFF" | | 70 || F || F | style="background:#FFFFFF" | | 102 || f || +F |- style="background:#F0F0F0" | 7 || BEL || $G | style="background:#FFFFFF" | | 39 || ' || /G | style="background:#FFFFFF" | | 71 || G || G | style="background:#FFFFFF" | | 103 || g || +G |- style="background:#F0F0F0" | 8 || BS || $H | style="background:#FFFFFF" | | 40 || ( || /H | style="background:#FFFFFF" | | 72 || H || H | style="background:#FFFFFF" | | 104 || h || +H |- style="background:#F0F0F0" | 9 || HT || $I | style="background:#FFFFFF" | | 41 || ) || /I | style="background:#FFFFFF" | | 73 || I || I | style="background:#FFFFFF" | | 105 || i || +I |- style="background:#F0F0F0" | 10 || LF || $J | style="background:#FFFFFF" | | 42 || * || /J | style="background:#FFFFFF" | | 74 || J || J | style="background:#FFFFFF" | | 106 || j || +J |- style="background:#F0F0F0" | 11 || VT || $K | style="background:#FFFFFF" | | 43 || + || /K | style="background:#FFFFFF" | | 75 || K || K | style="background:#FFFFFF" | | 107 || k || +K |- style="background:#F0F0F0" | 12 || FF || $L | style="background:#FFFFFF" | | 44 ||, || /L | style="background:#FFFFFF" | | 76 || L || L | style="background:#FFFFFF" | | 108 || l || +L |- style="background:#F0F0F0" | 13 || CR || $M | style="background:#FFFFFF" | | 45 || - || - | style="background:#FFFFFF" | | 77 || M || M | style="background:#FFFFFF" | | 109 || m || +M |- style="background:#F0F0F0" | 14 || SO || $N | style="background:#FFFFFF" | | 46 || . || . | style="background:#FFFFFF" | | 78 || N || N | style="background:#FFFFFF" | | 110 || n || +N |- style="background:#F0F0F0" | 15 || SI || $O | style="background:#FFFFFF" | | 47 || / || /O | style="background:#FFFFFF" | | 79 || O || O | style="background:#FFFFFF" | | 111 || o || +O |- style="background:#F0F0F0" | 16 || DLE || $P | style="background:#FFFFFF" | | 48 || 0 || 0 | style="background:#FFFFFF" | | 80 || P || P | style="background:#FFFFFF" | | 112 || p || +P |- style="background:#F0F0F0" | 17 || DC1 || $Q | style="background:#FFFFFF" | | 49 || 1 || 1 | style="background:#FFFFFF" | | 81 || Q || Q | style="background:#FFFFFF" | | 113 || q || +Q |- style="background:#F0F0F0" | 18 || DC2 || $R | style="background:#FFFFFF" | | 50 || 2 || 2 | style="background:#FFFFFF" | | 82 || R || R | style="background:#FFFFFF" | | 114 || r || +R |- style="background:#F0F0F0" | 19 || DC3 || $S | style="background:#FFFFFF" | | 51 || 3 || 3 | style="background:#FFFFFF" | | 83 || S || S | style="background:#FFFFFF" | | 115 || s || +S |- style="background:#F0F0F0" | 20 || DC4 || $T | style="background:#FFFFFF" | | 52 || 4 || 4 | style="background:#FFFFFF" | | 84 || T || T | style="background:#FFFFFF" | | 116 || t || +T |- style="background:#F0F0F0" | 21 || NAK || $U | style="background:#FFFFFF" | | 53 || 5 || 5 | style="background:#FFFFFF" | | 85 || U || U | style="background:#FFFFFF" | | 117 || u || +U |- style="background:#F0F0F0" | 22 || SYN || $V | style="background:#FFFFFF" | | 54 || 6 || 6 | style="background:#FFFFFF" | | 86 || V || V | style="background:#FFFFFF" | | 118 || v || +V |- style="background:#F0F0F0" | 23 || ETB || $W | style="background:#FFFFFF" | | 55 || 7 || 7 | style="background:#FFFFFF" | | 87 || W || W | style="background:#FFFFFF" | | 119 || w || +W |- style="background:#F0F0F0" | 24 || CAN || $X | style="background:#FFFFFF" | | 56 || 8 || 8 | style="background:#FFFFFF" | | 88 || X || X | style="background:#FFFFFF" | | 120 || x || +X |- style="background:#F0F0F0" | 25 || EM || $Y | style="background:#FFFFFF" | | 57 || 9 || 9 | style="background:#FFFFFF" | | 89 || Y || Y | style="background:#FFFFFF" | | 121 || y || +Y |- style="background:#F0F0F0" | 26 || SUB || $Z | style="background:#FFFFFF" | | 58 || : || /Z | style="background:#FFFFFF" | | 90 || Z || Z | style="background:#FFFFFF" | | 122 || z || +Z |- style="background:#F0F0F0" | 27 || ESC ||%A | style="background:#FFFFFF" | | 59 || ; ||%F | style="background:#FFFFFF" | | 91 || [ ||%K | style="background:#FFFFFF" | | 123 || { ||%P |- style="background:#F0F0F0" | 28 || FS ||%B | style="background:#FFFFFF" | | 60 || < ||%G | style="background:#FFFFFF" | | 92 || \ ||%L | style="background:#FFFFFF" | | 124 || {{pipe}} ||%Q |- style="background:#F0F0F0" | 29 || GS ||%C | style="background:#FFFFFF" | | 61 || = ||%H | style="background:#FFFFFF" | | 93 || ] ||%M | style="background:#FFFFFF" | | 125 || } ||%R |- style="background:#F0F0F0" | 30 || RS ||%D | style="background:#FFFFFF" | | 62 || > ||%I | style="background:#FFFFFF" | | 94 || ^ ||%N | style="background:#FFFFFF" | | 126 || ~ ||%S |- style="background:#F0F0F0" | 31 || US ||%E | style="background:#FFFFFF" | | 63 || ? ||%J | style="background:#FFFFFF" | | 95 || _ ||%O | style="background:#FFFFFF" | | 127 || DEL ||%T, %X, %Y, %Z |} ==Software== The following [[free and open source software]] can produce Code 39 barcodes: * [https://www.gnu.org/software/barcode/ GNU Barcode].<ref>{{cite web|title=GNU Barcode|date=19 February 2020|url=https://www.gnu.org/software/barcode/|publisher=[[GNU Project]]}}</ref> * [https://github.com/zint/zint Zint and libzint]. * [https://github.com/jimevins/glbarcode glbarcode++] and [https://github.com/jimevins/glabels-qt glabels] ==References== {{Reflist|30em}} {{Barcodes}} <!--Interwikies--> <!--Categories--> [[Category:Barcodes]] [[pt:Código de barras#Código 39]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Barcodes
(
edit
)
Template:Cite journal
(
edit
)
Template:Cite web
(
edit
)
Template:Nobr
(
edit
)
Template:Nobreak
(
edit
)
Template:Pipe
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)