The following codes are described here: UPC and EAN, Code-128, 2/5 Codes, Codabar (Monarch), MSI (Plessey), Code 39, Code 11, Code 93, Postal codes and CMC-7.
Above the UPC-A format is shown. It encodes a 12 digit number; the first 11 are the true number, the 12-th is a check digit. Each digit is coded as four bars, two black and two white. Bar width is from 1 to 4 units, the overall width for each digit is 7 units. The code is lead in and terminated by a start/stop code and in the middle there is a center code. The coding used allows 20 possible variations in 10 pairs, where the members are left-right reversals of each other. Each pair is assigned to a digit. Of the 2 pairs one code is normally used (and in UPC-A exclusively), the second is the same with left-right reversal (and not used in UPC-A). Normal codes have even total bar width in first and third position. Including start/stop and center codes the assignments are as follows (giving the widths of the succesive bars here):
0 3211 1123 1 2221 1222 2 2122 2212 3 1411 1141 4 1132 2311 5 1231 1321 6 1114 4111 7 1312 2131 8 1213 3121 9 3112 2113 start 111 stop 111 center 11111Due to the coding digits in the left part start with a white bar and digits in the right part with a black bar. The coding makes it possible to read either way and to determine what way actual reading is done.
Here we show UPC-E which is a zero-suppression form of UPC-A. It can only be used for numbers in "number system" 0. The following table gives the suppressions allowed:
Original number Shortened version 0 d1 d2 0 0 0 0 0 d3 d4 d5 d1 d2 d3 d4 d5 0 0 d1 d2 1 0 0 0 0 d3 d4 d5 d1 d2 d3 d4 d5 1 0 d1 d2 2 0 0 0 0 d3 d4 d5 d1 d2 d3 d4 d5 2 0 d1 d2 d3 0 0 0 0 0 d4 d5 d1 d2 d3 d4 d5 3 0 d1 d2 d3 d4 0 0 0 0 0 d5 d1 d2 d3 d4 d5 4 0 d1 d2 d3 d4 d5 0 0 0 0 5 d1 d2 d3 d4 d5 5 0 d1 d2 d3 d4 d5 0 0 0 0 6 d1 d2 d3 d4 d5 6 0 d1 d2 d3 d4 d5 0 0 0 0 7 d1 d2 d3 d4 d5 7 0 d1 d2 d3 d4 d5 0 0 0 0 8 d1 d2 d3 d4 d5 8 0 d1 d2 d3 d4 d5 0 0 0 0 9 d1 d2 d3 d4 d5 9Note that for instance "0 d1 d2 2 0 0 0 0 0 d4 d5" could be shortened to "d1 d2 0 d4 d5 2" and to "d1 d2 2 d4 d5 3".
check digit Normal/Reverse 0 RRRNNN 1 RRNRNN 2 RRNNRN 3 RRNNNR 4 RNRRNN 5 RNNRRN 6 RNNNRR 7 RNRNRN 8 RNRNNR 9 RNNRNRThese reversals made it necessary to use a different stop code to allow reading either way.
Above we see EAN-13. This is similar to UPC-A but it encodes one additional
digit. In fact UPC-A is a subset of EAN-13 if we prepend the UPC number with
an additional zero digit.
The first digits encode the country of origin, the remainder manufacturer
and product number as in UPC-A. There are also some special leading codes,
viz. 977 to 99.
Check-digit calculation is done in the same way as with UPC-A.
In EAN-13 all digits (except the leading one, but including the
check digit) are printed below the code; the leading digit is printed
to the left of that.
The leading digit is encoded by reversals in the left half of the code as
in the following table:
Leading digit Normal/Reverse 0 NNNNNN 1 NNRNRR 2 NNRRNR 3 NNRRRN 4 NRNNRR 5 NRRNNR 6 NRRRNN 7 NRNRNR 8 NRNRRN 9 NRRNRNThe use of reversal in the left half only makes it possible to do left-right and right-left reading without confusion (one half at least should have consistent codes). Note also that this table is extremely similar to the table for encoding the check digit in UPC-E, except for leading digit 0 which has no reversals (to allow UPC-A as a true subset).
The following leading codes are known to me:
00 -13 USA & Canada 2 reserved for local use (store/warehouse) 30 -37 France 380 Bulgaria 383 Slovenia 385 Croatia 387 Bornia and Herzegovina 400-440 Germany 45 Japan (see also 49) 46 Russian Federation 471 Taiwan 474 Estonia 475 Latvia 476 Azerbaijan 477 Lithuania 478 Uzbekistan 479 Sri Lanka 480 Philippines 481 Belarus 482 Ukraine 484 Moldova 485 Armenia 486 Georgia 487 Kazakhstan 489 Hong Kong 49 Japan (see also 45) 50 UK 520 Greece 528 Lebanon 529 Cyprus 531 Macedonia 535 Malta 539 Ireland 54 Belgium & Luxembourg 560 Portugal 569 Iceland 57 Danmark 590 Poland 594 Romania 599 Hungary 600-601 South Africa 608 Bahrain 609 Mauritius 611 Morocco 613 Algeria 616 Kenya 619 Tunisia 621 Syria 622 Egypt 624 Libya 625 Jordan 626 Iran 627 Kuwait 628 Saudi Arabia 629 United Arab Emirates 64 Finland 690-695 China 70 Norway 729 Israel 73 Sweden 740 Guatemala 741 El Salvador 742 Honduras 743 Nicaragua 744 Costa Rica 745 Panama 746 Republica Dominicana 750 Mexico 759 Venezuela 76 Switzerland 770 Colombia 773 Uruguay 775 Peru 777 Bolivia 779 Argentina 780 Chile 784 Paraguay 786 Ecuador 789-790 Brazil 80 -83 Italy 84 Spain 850 Cuba 858 Slovakia 859 Czechia 860 Yugoslavia 867 North Korea 869 Turkey 87 Netherlands 880 South Korea 885 Thailand 888 Singapore 890 India 893 Vietnam 899 Indonesia 90 -91 Austria 93 Australia 94 New Zealand 955 Papua New Guinea 958 Macau 977 ISSN 978 ISBN 979 ISMN 980 Refund receipts 981-982 Coupons in common currency 99 Coupons
This is EAN-8, a shortened version of EAN-13; it encodes 8 digits.
All digits are printed below the code. As in EAN-13 the leading
digits code the country of origin etc. The last digit is the check digit
calculated on the 7 digit product number. No special codings are
needed and performed.
UPC/EAN 2 digit extension
Both UPC-A and EAN-13 allow a 2 digit extension which is printed to the
right of the code and slightly lower, it is shown above accompanying
an UPC-A code. Digits are printed above it.
The code consists of a leader code (112) and digit codes separated by
a separation code (11). There is no trailer code as the full bar-code
disambiguates left-right and right-left reading. I have seen this code
used for volume numbers of periodicals for instance.
Some checking code is inserted. Multiply the first digit by 2 and add
the second digit to it; calculate the remainder when divided by 4.
This remainder is coded as follows:
remainder Normal/Reverse 0 NN 1 NR 2 RN 3 RRNote that this checking is very weak, but it is impossible to encode better checking in the code space allowed.
UPC-A and EAN-13 also allow a 5 digit extension, it is printed in a
fashion similar to the 2 digit extension and added to an EAN-13 code
in the example above. I have seen it used in the UK to encode
pricing and other things.
Also here some checking is performed. Take the second and fourth
digit and multiply by 3; add together and add to this the remaining
digits. The remainder when divided by 10 is coded as follows:
remainder Normal/Reverse 0 RRNNN 1 RNNNR 2 NNNRR 3 NNRNR 4 RNNRN 5 NNRRN 6 NRNNR 7 RNRNN 8 NRRNN 9 NRNRNNote that this coding is very dissimilar from the other Normal/Reverse codings used for single digit coding.
Code 128 enables one to encode all ASCII symbols plus numerous other things. The basics consists of bars and spaces, each 1 to 4 units wide for a total width of 11 units. This allows 214 different encodings. Of these only those are used that have an even number of black units (all codes start with a black bar), so 107 codes remain. There are 3 different codes available (and switching amongst them). Code A and B encode the middle half of the ASCII code table; Code A in addition encodes the first quarter and code B the last quarter (this uses the first 96 code positions). Code C codes all pairs of digits (this uses the first 100 code positions). The 4 positions used in Code C that do not encode symbols in code A or B are used for two special functions, a code that allows switching to code C and a code that signals that the following code has a meaning from the alternate code table.
In addition the next three codings are used for switching to code A and B and some special functions. The next three are start codes for all three codings and there is a stop code. The bar code is always terminated by a stop code followed by a bar of two units; the 107th code (211133) is not used because it would be a reverse reading of that terminating bar and part of the stop code (together 2331112).
For code A and B coding follows the ASCII code as follows (the third column is different for code A and B, code A is shown first, code B second).
Code A and B Code A and B Code A resp. B
SP 212222 @ 232121 NUL/' 111422
! 222122 A 111323 SOH/a 121124
" 222221 B 131123 STX/b 121421
# 121223 C 131321 ETX/c 141122
$ 121322 D 112313 EOT/d 141221
% 131222 E 132113 ENQ/e 112214
& 122213 F 132311 ACK/f 112412
' 122312 G 211313 BEL/g 122114
( 132212 H 231113 BS /h 122411
) 221213 I 231311 HT /i 142112
* 221312 J 112133 LF /j 142211
+ 231212 K 112331 VT /k 241211
, 112232 L 132131 FF /l 221114
- 122132 M 113123 CR /m 413111
. 122231 N 113321 SO /n 241112
/ 113222 O 133121 SI /o 134111
0 123122 P 313121 DLE/p 111242
1 123221 Q 211331 DC1/q 121142
2 223211 R 231131 DC2/r 121241
3 221132 S 213113 DC3/s 114212
4 221231 T 213311 DC4/t 124112
5 213212 U 213131 NAK/u 124211
6 223112 V 311123 SYN/v 411212
7 312131 W 311321 ETB/w 421112
8 311222 X 331121 CAN/x 421211
9 321122 Y 312113 EM /y 212141
: 321221 Z 312311 SUB/z 214121
; 312212 [ 332111 ESC/{ 412121
< 322112 \ 314111 FS /| 111143
= 322211 ] 221411 GS /} 111341
> 212123 ^ 431111 RS /~ 131141
? 212321 _ 111224 US/DEL 114113
For code C the numerical values are in order of the above table
00 upto and including 95.
Other codes:
Code A Code B Code C Coding Value FNC3 FNC3 96 114311 FNC2 FNC2 97 411113 shift shift 98 411311 Code C Code C 99 113141 Code B FNC4 Code B 114131 100 FNC4 Code A Code A 311141 101 FNC1 FNC1 FNC1 411131 102
Start/stop codes:
Code Coding Value Start A 211412 103 Start B 211214 104 Start C 211232 105 Stop 233111
For checksum purposes each coding (except the stop code) is assigned a value
which is the Code C value if it is numeric, otherwise it is the value shown
in the tables above. The value of the first code (including the start
code) is multiplied by 1; the second by 2 etc., this stops before the
stopcode. These values are added and the remainder modulo 103 is calculated.
The coding with this value is added as check code and finally the stopcode
and terminating bar are added.
2/5 Codes
This is a set of four related codes:
Industrial,
Interleave,
3-Bar (Data Logic) and
Interleave Special.
2/5 Industrial
In this code the white spacing is only significant to separate the black bars. Black bars come in two sizes, narrow (1 unit) and wide (2 units). A digit is encoded by five bars, two wide and three narrow; also there is a start and stop code as in the following table:
digit Narrow/Wide 0 NNWWN 1 WNNNW 2 NWNNW 3 WWNNN 4 NNWNW 5 WNWNN 6 NWWNN 7 NNNWW 8 WNNWN 9 NWNWN start WWN stop WNW
In contrast to the 2/5 Industrial code above in this code white space
has significance and comes in two widths. Each time two digits are coded,
one by the black bars and the other by the white spaces. The actual coding
with respect to wide and narrow is the same as above. However, there are
different start and stop codes, start is NNNN and stop is WNN both
alternating black and white.
2/5 3-Bar (Data Logic)
Similar to the 2/5 Interleave code, but here each digit is coded by
successive dark and white bars; no interleaving is performed. Digit
encoding is the same. The start is identical to the stop code and
encoded as XNWNW where X is an extra wide dark bar of 3 units.
2/5 Interleave Special
Similar to 2/5 interleave except that spacing is different.
A narrow black bar is 1 unit, a wide bar is 4 units; a narrow space is
2 units and a wide space 5 units.
Codabar (Monarch)
In this code dark and white bars come in 4 unit sizes, however dark bars are either 1 or 3 units and white bars 2 or 4 units. In addition to the digits a number of special symbols is encoded. Also there are 4 start/stop codes; these should be paired. All codes have 4 dark and 3 white bars, there is an interspacing white bar with unit size 2. The coding is as follows:
symbol code 0 1212143 1 1212341 2 1214123 3 3412121 4 1232141 5 3212141 6 1412123 7 1412321 8 1432121 9 3214121 $ 1234121 - 1214321 : 3212323 / 3232123 . 3232321 + 1232323 s/s 1234141 s/s 1414123 s/s 1214143 s/s 1214341
Each symbol is encoded in 4 dark and 4 white bars that come in two unit sizes, narrow and wide. The first bar is always dark. Also there are a stop and start symbol. Coding is as follows:
digit code 0 NWNWNWNW 1 NWNWNWWN 2 NWNWWNNW 3 NWNWWNWN 4 NWWNNWNW 5 NWWNNWWN 6 NWWNWNNW 7 NWWNWNWN 8 WNNWNWNW 9 WNNWNWWN start WN stop NWNNote: using NW for binary digit 0 and WN for binary digit 1 the coding becomes clear.
This code encodes many symbols. Each symbol is encoded by 5 dark bars and 4 white bars that can be narrow or wide, with 3 wide bars. A narrow white bar is used as interspacing. The coding is as follows:
symbol coding 0 NNNWWNWNN 1 WNNWNNNNW 2 NNWWNNNNW 3 WNWWNNNNN 4 NNNWWNNNW 5 WNNWWNNNN 6 NNWWWNNNN 7 NNNWNNWNW 8 WNNWNNWNN 9 NNWWNNWNN A WNNNNWNNW B NNWNNWNNW C WNWNNWNNN D NNNNWWNNW E WNNNWWNNN F NNWNWWNNN G NNNNNWWNW H WNNNNWWNN I NNWNNWWNN J NNNNWWWNN K WNNNNNNWW L NNWNNNNWW M WNWNNNNWN N NNNNWNNWW O WNNNWNNWN P NNWNWNNWN Q NNNNNNWWW R WNNNNNWWN S NNWNNNWWN T NNNNWNWWN U WWNNNNNNW V NWWNNNNNW W WWWNNNNNN X NWNNWNNNW Y WWNNWNNNN Z NWWNWNNNN - NWNNNNWNW . WWNNNNWNN space NWWNNNWNN s/s NWNNWNWNN $ NWNWNWNNN / NWNWNNNWN + NWNNNWNWN % NNNWNWNWNAn extended variant of this code can be used to encode the complete ASCII character set. In that case one of the symbols $, /, + or % followed by a letter encodes a different symbol (of course, many can be encoded as a plain symbol):
letter pre-$ pre-/ pre-+ pre-%
A SOH ! a ESC
B STX " b FS
C ETX # c GS
D EOT $ d RS
E ENQ % e US
F ACK & f ;
G BEL ' g <
H BS ( h =
I HT ) i >
J LF * j ?
K VT + k [
L FF , l \
M CR - m ]
N SO . n ^
O SI / o _
P DLE 0 p {
Q DC1 1 q |
R DC2 2 r }
S DC3 3 s ~
T DC4 4 t DEL
U NAK 5 u NUL
V SYN 6 v @
W ETB 7 w `
X CAN 8 x
Y EM 9 y
Z SUB : z
In this code each symbol has five elements (alternating black and white) of which either one or two are wide. In between symbols is a narrow white space. Further there is a start/stop element.
The coding is as follows:
symbol coding 0 NNNNW 1 WNNNW 2 NWNNW 3 WWNNN 4 NNWNW 5 WNWNN 6 NWWNN 7 NNNWW 8 WNNWN 9 WNNNN - NNWNN s/s NNWWNThe code also defines two check digits, for the purpose of check digit calculation the value of the hyphen is 10. The first check digit is calculated by multiplying the last value by 1, the last but one by 2, the one before by 3, etc.. When the weight has reached 10 the next value is multiplyed by 1 and continues again from there. The start/stop symbol is not used. These products are added together and the check digit is the remainder of this sum when divided by 11 (so it could become 10 which is coded as the hyphen). The second check digit is calculated in a similar way, but now starting by the first check digit. Moreover the maximum weight used is 9 and the remainder after division by 10 is calculated. This second check digit is often omitted when the number of digits is 10 or less.
Here a symbol consists of six elements, alternating black and white. A black element is 1 to 3 units wide, a white element 1 to 4 units, the total width of a symbol is 9 units. Except in the start/stop symbol, that has a 4 unit white black element. The code defines codes for all ASCII symbols, although many are only reachable by a letter prefixed by one of the four escape codes. (Note in the literature these four escape symbols are indicated as $ for ESC0, / for ESC1, + for ESC2 and % for ESC3, but the coding is different from the coding for just those four symbols, so I will consistently use ESCn for these. The reason for all this is that it is similar to the extended format used in Code 39.) Some symbols can be coded plain or by an escaped letter, the plain coding is (of course) the preferred one. In addition there is a start/stop symbol, and the code is terminated by a black one unit wide bar. Furthermore, for checksum purposes each symbol except the start/stop symbol has a value.
The coding is as follows (the widths of the elements is given):
code value symbol ESC0 ESC1 ESC2 ESC3
131112 0 0
111213 1 1
111312 2 2
111411 3 3
121113 4 4
121212 5 5
121311 6 6
111114 7 7
131211 8 8
141111 9 9
211113 10 A SOH ! a ESC
211212 11 B STX " b FS
211311 12 C ETX # c GS
221112 13 D EOT $ d RS
221211 14 E ENQ % e US
231111 15 F ACK & f ;
112113 16 G BEL ' g <
112212 17 H BS ( h =
112311 18 I HT ) i >
122112 19 J LF * j ?
132111 20 K VT + k [
111123 21 L FF , l \
111222 22 M CR - m ]
111321 23 N SO . n ^
121122 24 O SI / o _
131121 25 P DLE 0 p {
212112 26 Q DC1 1 q |
212211 27 R DC2 2 r }
211122 28 S DC3 3 s ~
211221 29 T DC4 4 t DEL
221121 30 U NAK 5 u NUL
222111 31 V SYN 6 v @
112122 32 W ETB 7 w `
112221 33 X CAN 8 x
122121 34 Y EM 9 y
123111 35 Z SUB : z
121131 36 -
311112 37 .
311211 38 SP
321111 39 $
112131 40 /
113121 41 +
211131 42 %
121221 43 ESC0
312111 44 ESC3
311121 45 ESC1
122211 46 ESC2
111141 - s/s
Check digit calculation is similar to that for code 11,
the only difference is the multiplying values and the values used for
remaindering. For the first check digit the maximal multiplying factor
is 20, and the remainder is done modulo 47. The second check digit has
a maximal multiplying factor of 15 with the same remaindering.
The US postnet code is used to encode the US Zip-code on mail. This can be either the 5 digit Zip-code, the 9 digit Zip+4-code or the 11 digit "delivery point"-code. Each digit is encoded with five bars, of which two are long and three are small. In addition there is a check digit added such that the sum of all digits encoded is a multiple of ten. Also there is a lead in and lead out of a single long bar. The coding is as follows:
digit code 1 SSSLL 2 SSLSL 3 SSLLS 4 SLSSL 5 SLSLS 6 SLLSS 7 LSSSL 8 LSSLS 9 LSLSS 0 LLSSS
In the UK the "ZIP"-code did not consist of digits only, so the UK Royal Mail devised a different code to encode all digits and letters. This code is also used in Canada and the Netherlands (amongst others) and not only for "ZIP"-codes. Here a small (black) bar can be extended either upwards or downwards or in both directions. A symbol is encoded by four bars, of which exactly two have an upwards extension and two have a downwards extension. So this is the combination of two 2 out of 4 codes that can encode precisely 36 symbols. In the table below the code is given by two times four symbols separated by a slash. In each case a plus symbols means that that bar is extended, the symbols before the slash are for upwards extensions while those after the slash are for downwards extensions.
symbol code 0 --++/--++ 1 --++/-+-+ 2 --++/-++- 3 --++/+--+ 4 --++/+-+- 5 --++/++-- 6 -+-+/--++ 7 -+-+/-+-+ 8 -+-+/-++- 9 -+-+/+--+ A -+-+/+-+- B -+-+/++-- C -++-/--++ D -++-/-+-+ E -++-/-++- F -++-/+--+ G -++-/+-+- H -++-/++-- I +--+/--++ J +--+/-+-+ K +--+/-++- L +--+/+--+ M +--+/+-+- N +--+/++-- O +-+-/--++ P +-+-/-+-+ Q +-+-/-++- R +-+-/+--+ S +-+-/+-+- T +-+-/++-- U ++--/--++ V ++--/-+-+ W ++--/-++- X ++--/+--+ Y ++--/+-+- Z ++--/++--
This code is similar to the code above. Each symbol consists of three bars, in each symbol both above and below one or two bars are extended. However, the number of extensions is the same. This code also has a lead in, consisting of two bars, the first extended above and below and the second only extended below. There is also a lead out of two bars, here the first bar is only extended below and the second bar extended on both sides. To enable the coding of letters, this code has three shift characters that change the meaning of the following symbol. In the table below codes are indicated by two groups of symbols, separated by a slash. Like with the code above a + indicates extension (when before the slash above, when after below) and a - indicates no extension. I do not know whether the empty places below also define symbols.
code normal shift1 shift2 shift3 ++-/++- 1 A K U +-+/++- 2 B L V -++/++- 3 C M W ++-/+-+ 4 D N X +-+/+-+ 5 E O Y -++/+-+ 6 F P Z ++-/-++ 7 G Q +-+/-++ 8 H R -++/-++ 9 I S +--/+-- 0 J T -+-/+-- sh1 --+/+-- sh2 +--/-+- sh3 -+-/-+- + --+/-+- space +--/--+ -+-/--+ --+/--+
This is a barcode you can see on post that is not required to carry a postage stamp; the barcode is printed instead. Originally used only in the US, it is now also used elsewhere. There are a few codes defined, above you see FIM-A, FIM-B, FIM-C, FIM-D and another one that I have seen. I know that in the US also FIM-E is defined now, but I do not know whether it is actually the fifth code I have seen. I will not go deeply into the function (it has to do with how postage dues are credited), only in the code. The code allows for 9 potential black bars separated by white bars, all of equal width. The outermost potential bars are always black, and the codes I know have always are symmetric. This gives the following table (marking only the potentially black bars, and leaving the meaning for those I do now know empty):
code meaning x-------x x---x---x x--x-x--x x--xxx--x x-x---x-x x-x-x-x-x x-xx-xx-x FIM-B x-xxxxx-x xx-----xx xx--x--xx FIM-A xx-x-x-xx FIM-C xx-xxx-xx xxx---xxx xxx-x-xxx FIM-D xxxx-xxxx seen? xxxxxxxxx