Free Barcode Fonts @ dobsonsw.com
Need help? See The Forum!
Code128 Barcode Information

Barcode Tools
 

Code128 Barcode Information Barcode Font Home
Code128 Barcode Information Online Barcodes
Code128 Barcode Information Desktop Barcodes
Code128 Barcode Information 
Barcodes For Excel 
Word Barcode
Postnet For Excel
Code128 Barcode Information 
Barcodes For Word®
 Word® Barcode Tutorial
Word Barcode Product Support
 Installing Barcode Fonts
Code128 Barcode Information Contact Us
 Affiliate Program
Code128 Barcode Information Consulting

View Cart

 
 

Developer Support
  Code128 Barcode Information Barcode Font Home
Code128 Barcode Information Code128 Samples
Code128 Barcode Information Code128 Specs
 Installing Barcode Fonts
Code128 Barcode Information Preview Code128 DLL
Code128 Barcode Information Commercial Licensing
Code128 Barcode Information Consulting
 
 
Code 128 Specification:

Developers, looking for a quick Code 128 implementation? Check out the DLL for Windows and the UFL for Crystal Reports.

The following table and pseudo code is illustrated based on the free Code 128 Font found at Free Barcode Fonts. While the check digit calculation is the same with all Code 128 barcodes the location of characters within the fonts differ. There is some sample code available here.

The following table illustrates the Code 128 Value, the value of Variant B and C, and the ASCII location of the character within my Code 128 font set found at Free Barcode Fonts . If you are dealing with Unicode you will need to make the conversion between unicode and the ASCII value.

When dealing with Code 128 it is always advisable to think of a character as the Code 128 Value rather than the actual character. For instance, don't think of a capital A as a capital A. It's much easier to think of it as a Variant B code 33.

Code 128 Definitions
 (High ASCII is Win Latin & should be converted to Unicode for international applications)
Code 128 Variant B Variant C ASCII Unicode  Code 128 Variant B Variant C ASCIIUnicode
0 Space 00 128 20AC  54 V 54 86
1 ! 01 33   55 W 55 87
2 " 02 34   56 X 56 88
3 # 03 35   57 Y 57 89
4 $ 04 36   58 Z 58 90
5 % 05 37   59 [ 59 91
6 & 06 38   60 \ 60 92
7 ' 07 39   61 ] 61 93
8 ( 08 40   62 ^ 62 94
9 ) 09 41   63 _ 63 95
10 * 10 42   64 ' 64 96
11 + 11 43   65 a 65 97
12 , 12 44   66 b 66 98
13 - 13 45   67 c 67 99
14 . 14 46   68 d 68 100
15 / 15 47   69 e 69 101
16 0 16 48   70 f 70 102
17 1 17 49   71 g 71 103
18 2 18 50   72 h 72 104
19 3 19 51   73 i 73 105
20 4 20 52   74 j 74 106
21 5 21 53   75 k 75 107
22 6 22 54   76 l 76 108
23 7 23 55   77 m 77 109
24 8 24 56   78 n 78 110
25 9 25 57   79 o 79 111
26 : 26 58   80 p 80 112
27 ; 27 59   81 q 81 113
28 < 28 60   82 r 82 114
29 = 29 61   83 s 83 115
30 > 30 62   84 t 84 116
31 ? 31 63   85 u 85 117
32 @ 32 64   86 v 86 118
33 A 33 65   87 w 87 119
34 B 34 66   88 x 88 120
35 C 35 67   89 y 89 121
36 D 36 68   90 z 90 122
37 E 37 69   91 { 91 123
38 F 38 70   92 | 92 124
39 G 39 71   93 } 93 125
40 H 40 72   94 ~ 94 126
41 I 41 73   95 DEL 95 1452018
42 J 42 74   96 FNC 3 96 1462019
43 K 43 75   97 FNC 2 97 147201C
44 L 44 76   98 SHIFT 98 148201D
45 M 45 77   99 CODE C 99 1492022
46 N 46 78   100 FNC 4 CODE B 1502013
47 O 47 79   101 CODE A CODE A 1512014
48 P 48 80   102 FNC 1 FNC 1 15202DC
49 Q 49 81   103 START A START A 1532122
50 R 50 82   104 START B START B 1540161
51 S 51 83   105 START C START C 155203A
52 T 52 84   106 STOP STOP 1560153
53 U 53 85          

 

Converting between ASCII and Code 128

The font was written to allow an algorithmic conversion between Code 128 and ASCII. While it's possible to use a lookup table to find your information it's also quite easy to make the transformation algorithmically. Three steps are required.

Converting from Code 128 to ASCII:
1) Check for Code 128 value 0 [Variant B Space, Variant C 00] If Code 128 value is 0 than ASCII value equals 128
2) If Code 128 value is between 1 and 94 inclusive than ASCII value equals Code 128 value + 32
3) If Code 128 value is greater than 94 than ASCII value equals Code 128 Value + 50

For instance, Code 128 value 0 will equal ASCII value 128. Code 128 Value 1 [Variant B !, Variant C 01] will equal 1 + 32 equals ASCII value of 33. Code 128 value 98 [Variant B SHIFT, Variant C 98] will equal 98 + 50 equals ASCII Value of 148.

The same steps can be used in reverse to find a Code 128 Value from an ASCII character.

Converting from ASCII to Code 128 Value:
1) If the ASCII value is 128 then the Code 128 Value equals 0
2) If the ASCII value is between 33 and 126 inclusive than the Code 128 Value equals the ASCII value - 32.
3) If the ASCII value is greater than 126, but not 128, then the Code 128 value equals the ASCII value - 50.

Converting Variant C to ASCII is a bit different. Outside of the special characters, the Code 128 value and the Variant C value is the same. For instance, Variant C '25' equals Code 128 25. This makes the conversion quite easy when dealing with a two character string. The code 128 value is already encoded in the string itself.

Check Digit Calculation:

Basic calculation of the Code 128 check digit is pretty easy. For expedience I will use straight variant B. However, you should be aware that code 128 allows multiple variant encoding in a single barcode. You can encode variant A, variant B, and variant C in a single barcode to take up less space.

To begin encoding you will keep a running total of the checksum of each character. The checksum is weighted based on the location of each particular character. For instance, the first character is weighted by 1. The second by 2, etc, etc, etc. To start, lets assume that we are encoding the value 'Code 128' as a barcode in variant B. The structure and checksum is as follows:

Character
START B
C
O
D
E
1
2
8
Code 128 Value
104
35
47
36
37
17
18
24
Weight
-
1
2
3
4
5
6
7
Checksum
104
35 * 1
47 * 2
36 * 3
37 * 4
17 * 5
18 * 6
24 * 7
Value
104
35
94
108
148
85
108
168

As you can see calculation of the weighted values is quite easily accomplished. To calculate the actual check digit one needs to add the values together and apply modulos 103 to the sum of the weighted values. In the above case the total checksum value is 104 + 35 + 94 + 108 + 148 + 85 + 108 + 168 = 850. 850 MOD 103 = 26. Therefore, the check digit for this barcode would be code 26 of the Code 128 set, which in ASCII terms would be ASCII 58, or the character ':'

To complete the barcode we simply add the check digit and the stop character located at ASCII 156, Code 128 value 106, to result in:

[START B] C O D E 1 2 8 : [STOP]

Code 128 Structure:

As you can see in the example above Code 128 is structured by a start character, indicating the starting variant, the data itself, followed by the check digit, and ultimately ending up with the stop character:

[START VARIANT][DATA CHARACTERS][CHECK DIGIT][STOP]

Code128 Barcode InformationDeveloper Notes:

Writing for code 128? This should get you on your way. It's not as confusing as it looks and remember, the Code128 DLL is available to make life much easier.

 


Copyright 2008-2011 Brian Dobson .All Rights Reserved