双11上云狂欢,0.5折起爆品开抢
Logo

博客

2018-3-20 xoyozo 转载请注明出处

Code 128 条形码可以表示全部 128 个 ASCII 码字符(数字、大小写字母、符号和控制符)。

Code 128 有三个子集:Code 128A、Code 128B 和 Code 128C。

Code 128A 用来编码数字、大写字母、控制符、部分符号;

Code 128B 用来编码数字、大写字母、小写字母、符号;

Code 128C 用来编码 2 位数字 [00,99]。


  • 码条大小有 4 种,按照宽度,我们用 1、2、3、4 来表示。

  • 一个完整的 Code 128 条码是由:起始符、字符串、检验位、终止符组成的。

  • 每个字符由 3 个条、3 个空、11 个单元构成,字符串可变长。

  • 黑色线条用 B(Bar)表示,白色空位用 S(Space)表示,那么一个字符是由 BSBSBS 组成的。

  • 起始符有三种,“CODE-A”、“CODE-B”和“CODE-C”。起始符的类型决定了后面字符的构成。

CODE 128构成

  • 当采用码来设置字符时(CODE-A、CODE-B 和 CODE-C),起始符为 CODE-A 的条码在条码的处理中可以变为采用 CODE-B 或 CODE-C 栏的字符。

  • 当采用“SHIFT”时,只有紧靠 SHIFT 的一个字符可以在下一栏被变更(A 到 B,B 到 C,C 到 A)。(和电脑键盘上的 SHIFT 键操作类似)


校验字符通过 MOD103 算法,下面举例说明:

例 1:xoyozo.net
信息:StartB x o y o z o . n e t
值:104 88 79 89 79 90 79 14 78 69 84
位置:- 1 2 3 4 5 6 7 8 9 10
计算:104 + 88 * 1+ 79 * 2 + 89 * 3 + 79 * 4 +90 * 5 + 79 * 6 + 14 * 7 + 78 * 8 + 69 * 9 + 84 * 10 = 4040
取模:4040 % 103 = 23
完整的条形码信息: (Start B)xoyozo.net(7)(STOP)

例 2:C08244
信息:StartB C 0 CodeC 82 44
值:104 35 16 99 82 44
位置:- 1 2 3 4 5 6
计算:104 + 35 * 1+ 16 * 2 + 99 * 3 + 82 * 4 +44 * 5 = 1016
取模:1016 % 103 = 89
完整的条形码信息: (Start B)C0(CodeC)8244(y)(STOP)


在线示例:https://xoyozo.net/Tools/Code128


附 Code 128 编码表:

ValueCode ACode BCode CPatternASCII Code
BSBSBS
0SPSP00212222SP (ASCII 32)
1!!01222122! (ASCII 33)
2""02222221" (ASCII 34)
3##03121223# (ASCII 35)
4$$04121322$ (ASCII 36)
5%%05131222% (ASCII 37)
6&&06122213& (ASCII 38)
7''07122312' (ASCII 39)
8((08132212( (ASCII 40)
9))09221213) (ASCII 41)
10**10221312* (ASCII 42)
11++11231212+ (ASCII 43)
12,,12112232, (ASCII 44)
13--13122132- (ASCII 45)
14..14122231. (ASCII 46)
15//15113222/ (ASCII 47)
1600161231220 (ASCII 48)
1711171232211(ASCII 49)
1822182232112 (ASCII 50)
1933192211323 (ASCII 51)
2044202212314 (ASCII 52)
2155212132125 (ASCII 53)
2266222231126 (ASCII 54)
2377233121317 (ASCII 55)
2488243112228 (ASCII 56)
2599253211229 (ASCII 57)
26::26321221: (ASCII 58)
27;;27312212; (ASCII 59)
28<<28322112< (ASCII 60)
29==29322211= (ASCII 61)
30>>30212123> (ASCII 62)
31??31212321? (ASCII 63)
32@@32232121@ (ASCII 64)
33AA33111323A (ASCII 65)
34BB34131123B (ASCII 66)
35CC35131321C (ASCII 67)
36DD36112313D (ASCII 68)
37EE37132113E (ASCII 69)
38FF38132311F (ASCII 70)
39GG39211313G (ASCII 71)
40HH40231113H (ASCII 72)
41II41231311I (ASCII 73)
42JJ42112133J (ASCII 74)
43KK43112331K (ASCII 75)
44LL44132131L (ASCII 76)
45MM45113123M (ASCII 77)
46NN46113321N (ASCII 78)
47OO47133121O (ASCII 79)
48PP48313121P (ASCII 80)
49QQ49211331Q (ASCII 81)
50RR50231131R (ASCII 82)
51SS51213113S (ASCII 83)
52TT52213311T (ASCII 84)
53UU53213131U (ASCII 85)
54VV54311123V (ASCII 86)
55WW55311321W (ASCII 87)
56XX56331121X (ASCII 88)
57YY57312113Y (ASCII 89)
58ZZ58312311Z (ASCII 90)
59[[59332111[ (ASCII 91)
60\\60314111\ (ASCII 92)
61]]61221411] (ASCII 93)
62^^62431111^ (ASCII 94)
63__63111224_ (ASCII 95)
64NUL`64111422` (ASCII 96)
65SOHa65121124a (ASCII 97)
66STXb66121421b (ASCII 98)
67ETXc67141122c (ASCII 99)
68EOTd68141221d (ASCII 100)
69ENQe69112214e (ASCII 101)
70ACKf70112412f (ASCII 102)
71BELg71122114g (ASCII 103)
72BSh72122411h (ASCII 104)
73HTi73142112i (ASCII 105)
74LFj74142211j (ASCII 106)
75VTk75241211k (ASCII 107)
76FFl76221114l (ASCII 108)
77CRm77413111m (ASCII 109)
78SOn78241112n (ASCII 110)
79SIo79134111o (ASCII 111)
80DLEp80111242p (ASCII 112)
81DC1q81121142q (ASCII 113)
82DC2r82121241r (ASCII 114)
83DC3s83114212s (ASCII 115)
84DC4t84124112t (ASCII 116)
85NAKu85124211u (ASCII 117)
86SYNv86411212v (ASCII 118)
87ETBw87421112w (ASCII 119)
88CANx88421211x (ASCII 120)
89EMy89212141y (ASCII 121)
90SUBz90214121z (ASCII 122)
91ESC{91412121{ (ASCII 123)
92FS|92111143| (ASCII 124)
93GS}93111341} (ASCII 125)
94RS~94131141~ (ASCII 126)
95 (Hex 7F)USDEL95114113DEL (ASCII 127)
96 (Hex 80)FNC 3FNC 396114311Ç (ASCII 128)
97 (Hex 81)FNC 2FNC 297411113ü (ASCII 129)
98 (Hex 82)SHIFTSHIFT98411311é (ASCII 130)
99 (Hex 83)CODE CCODE C99113141â (ASCII 131)
100 (Hex 84)CODE BFNC 4CODE B114131ä (ASCII 132)
101 (Hex 85)FNC 4CODE ACODE A311141à (ASCII 133)
102 (Hex 86)FNC 1FNC 1FNC 1411131å (ASCII 134)
103 (Hex 87)START (Code A)211412‡ (ASCII 135)
104 (Hex 88)START (Code B)211214ˆ (ASCII 136)
105 (Hex 89)START (Code C)211232‰ (ASCII 137)
106 (Hex 6A)STOP (All Codes)2331112Š (ASCII 138)
5,807 阅读