Code 128: Wikis

Advertisements
  
  

Note: Many of our articles have direct quotes from sources you can cite, within the Wikipedia article! This article doesn't yet, but we're working on it! See more info or our list of citable articles.

Encyclopedia

From Wikipedia, the free encyclopedia

"Wikipedia" encoded in Code 128-B

Code 128 is a very high-density barcode symbology. (A special version of it called GS1-128 is used extensively world wide in shipping and packaging industries.) It is used for alphanumeric or numeric-only barcodes. It can encode all 128 characters of ASCII and, by use of an extension character (FNC4), the Latin-1 characters defined in ISO/IEC 8859-1[citation needed]. GS1-128 (formerly known as UCC/EAN-128), not Code 128, is the major component of the labeling standard for GS1 used as product identification for container and pallet levels in the supply chain. The symbology was formerly defined as ISO/IEC 15417:2007.

Contents

Specification

A Code 128 barcode will have six sections:

  • Quiet Zone
  • Start Character
  • Encoded Data
  • Check Character
  • Stop Character
  • Quiet Zone

The check character is calculated from a weighted sum (modulo 103) of all the characters.

Advertisements

Subtypes

Code 128 actually includes 107 symbols: 103 data symbols, 3 start codes, and 1 stop code. To represent all 128 ASCII values, there are actually three subcodes, which can be mixed within a single barcode:

  • 128A - ASCII characters 00 to 95 (0-9, A-Z and control codes) and special characters
  • 128B - ASCII characters 32 to 127 (0-9, A-Z, a-z) and special characters
  • 128C - 00-99 (double density encoding of numeric only data) and FNC1

Quiet Zone

The quiet zone should be at least ten times the width of the narrowest bar/space element.

Start/Stop and Encoded Data

Each character in the barcode symbol is composed of three bars and three spaces. (The stop adds an additional extra bar of length 2.) Each bar or space is 1, 2, 3 or 4 units wide, the sum of the widths of bars must be even, the sum of the widths of the spaces must be odd, and total 11 units per character. For instance, encoding the ASCII value 0 can be viewed as 10011101100, where a 1 is a bar and a 0 is a space. A combination which contains a single 1 would be the thinnest line in the bar code. A combination including three 1 (111) in sequence indicates a bar three times as thick as a single 1 bar. More information is available at Barcode Island.

Check Digit Calculation

The check digit is a Modulo 103 checksum. It is calculated by summing the start code 'value' to the products of each character's 'value' multiplied by its position in the barcode string. The left most character is position 1. The sum of the start code value and the products is divided by 103. The remainder is the check digit's 'value'.

Calculating Check Digit With Multiple Variants

As Code 128 allows multiple variants, as well as switching between variants within a single barcode, it is important to remember that the absolute Code 128 value of a character is completely independent of its value within a given variant. For instance the Variant C value "33" and the Variant B value "A" are both considered to be a Code 128 value of 33, and the check digit would be computed based on the value of 33 times the character's position within the barcode. A complete table of Variant B and C values, as well as algorithmic conversion between Code 128 values and ASCII values, is available here.

Bar Code Widths

Code128 specifies a combination of 6 bars and spaces for each character except the Stop character, which uses 7. Thus, each character begins with a bar and ends with a space (with the exception of the stop character, which ends in a bar). The following tables detail the widths associated with each bar and space for each character. The width of each bar or space can be 1, 2, 3 or 4 units. Using the example above, an 'A' would be depicted as 10100011000, or as 111323 in the tables below.

Code 128
Value Bar/Space Weights 128A 128B 128C
0 212222 space space 00
1 222122  !  ! 01
2 222221 " " 02
3 121223 # # 03
4 121322 $ $ 04
5 131222  %  % 05
6 122213 & & 06
7 122312 ' ' 07
8 132212 ( ( 08
9 221213 ) ) 09
10 221312 * * 10
11 231212 + + 11
12 112232 , , 12
13 122132 - - 13
14 122231 . . 14
15 113222 / / 15
16 123122 0 0 16
17 123221 1 1 17
18 223211 2 2 18
19 221132 3 3 19
20 221231 4 4 20
21 213212 5 5 21
22 223112 6 6 22
23 312131 7 7 23
24 311222 8 8 24
25 321122 9 9 25
26 321221  :  : 26
27 312212  ;  ; 27
28 322112 < < 28
29 322211 = = 29
30 212123 > > 30
31 212321  ?  ? 31
32 232121 @ @ 32
33 111323 A A 33
34 131123 B B 34
35 131321 C C 35
36 112313 D D 36
37 132113 E E 37
38 132311 F F 38
39 211313 G G 39
40 231113 H H 40
41 231311 I I 41
42 112133 J J 42
43 112331 K K 43
44 132131 L L 44
45 113123 M M 45
46 113321 N N 46
47 133121 O O 47
48 313121 P P 48
49 211331 Q Q 49
50 231131 R R 50
51 213113 S S 51
52 213311 T T 52
53 213131 U U 53
54 311123 V V 54
55 311321 W W 55
56 331121 X X 56
57 312113 Y Y 57
58 312311 Z Z 58
59 332111 [ [ 59
60 314111 \ \ 60
61 221411 ] ] 61
62 431111 ^ ^ 62
63 111224 _ _ 63
64 111422 NUL ` 64
65 121124 SOH a 65
66 121421 STX b 66
67 141122 ETX c 67
68 141221 EOT d 68
69 112214 ENQ e 69
70 112412 ACK f 70
71 122114 BEL g 71
72 122411 BS h 72
73 142112 HT i 73
74 142211 LF j 74
75 241211 VT k 75
76 221114 FF l 76
77 413111 CR m 77
78 241112 SO n 78
79 134111 SI o 79
80 111242 DLE p 80
81 121142 DC1 q 81
82 121241 DC2 r 82
83 114212 DC3 s 83
84 124112 DC4 t 84
85 124211 NAK u 85
86 411212 SYN v 86
87 421112 ETB w 87
88 421211 CAN x 88
89 212141 EM y 89
90 214121 SUB z 90
91 412121 ESC { 91
92 111143 FS | 92
93 111341 GS } 93
94 131141 RS ~ 94
95 114113 US DEL 95
96 114311 FNC 3 FNC 3 96
97 411113 FNC 2 FNC 2 97
98 411311 Shift B Shift A 98
99 113141 Code C Code C 99
100 114131 Code B FNC4 Code B
101 311141 FNC 4 Code A Code A
102 411131 FNC 1 FNC 1 FNC 1
103 211412 Start Code A
104 211214 Start Code B
105 211232 Start Code C
106 2331112 Stop

The "Code A", "Code B" and "Code C" symbols cause all future symbols to be interpreted according to the corresponding subcode. The "Shift" symbol switches a single following symbol's interpretation between subcodes A and B.

The FNCx codes are used for special purposes. FNC1 at the beginning of a bar code indicates that it begins with a 2- 3- or 4-digit application identifier assigned by the Uniform Code Council, which explains the following digits. For example, application identifier 421 indicates that an ISO 3166-1 numeric country code and ship-to postal code follows. For example, the U.S. ZIP code for the White House would generally be printed as "(421) 840 20500", but would actually be coded as "[Start C] [FNC1] 42 18 40 20 50 [Code A] 0 [Check symbol 80] [Stop]"

Availability

For the end user, Code 128 barcodes may be generated by either an outside application to create an image of the barcode, or by a font based barcode solution. Either solution requires the use of an application or an application add in to calculate the check digit and create the barcode.

External links

Sample code

  • Python Bar Code 128 This code appears to draw boxes 1 pixel wide. It appears it was modified from a short line long line bar code which would have drawn lines. The "Black boxes" should be the same size as the "White Boxes".
  • GenCode128 Free C# source code implementation of Code128. Almost all features are implemented, but is not 100% complete.
  • Barcode Image Generation Library Free C# barcode generation library implementation supporting many barcode symbologies including Code128.
  • Barcode::Code128 Free Perl barcode generation module.
  • GOCR Free OCR with Code 128 recognition.
  • Barcode Code 128 Free JavaScript source code implementation of Code128.

Advertisements






Got something to say? Make a comment.
Your name
Your email address
Message