asp生成 code128条形码(支持字母和数字)另附Code128 字符表

asp生成 code128条形码(支持字母和数字)

在原来只支持数字的基础上增加了支持字母的功能,代码如下:

<%


'On Error Resume Next
Dim barcode(106)
barcode(0)="||_||__||__"
barcode(1)="||__||_||__"
barcode(2)="||__||__||_"
barcode(3)="|__|__||___"
barcode(4)="|__|___||__"
barcode(5)="|___|__||__"
barcode(6)="|__||__|___"
barcode(7)="|__||___|__"
barcode(8)="|___||__|__"
barcode(9)="||__|__|___"
barcode(10)="||__|___|__"
barcode(11)="||___|__|__"
barcode(12)="|_||__|||__"
barcode(13)="|__||_|||__"
barcode(14)="|__||__|||_"
barcode(15)="|_|||__||__"
barcode(16)="|__|||_||__"
barcode(17)="|__|||__||_"
barcode(18)="||__|||__|_"
barcode(19)="||__|_|||__"
barcode(20)="||__|__|||_"
barcode(21)="||_|||__|__"
barcode(22)="||__|||_|__"
barcode(23)="|||_||_|||_"
barcode(24)="|||_|__||__"
barcode(25)="|||__|_||__"
barcode(26)="|||__|__||_"
barcode(27)="|||_||__|__"
barcode(28)="|||__||_|__"
barcode(29)="|||__||__|_"
barcode(30)="||_||_||___"
barcode(31)="||_||___||_"
barcode(32)="||___||_||_"
barcode(33)="|_|___||___"
barcode(34)="|___|_||___"
barcode(35)="|___|___||_"
barcode(36)="|_||___|___"
barcode(37)="|___||_|___"
barcode(38)="|___||___|_"
barcode(39)="||_|___|___"
barcode(40)="||___|_|___"
barcode(41)="||___|___|_"
barcode(42)="|_||_|||___"
barcode(43)="|_||___|||_"
barcode(44)="|___||_|||_"
barcode(45)="|_|||_||___"
barcode(46)="|_|||___||_"
barcode(47)="|___|||_||_"
barcode(48)="|||_|||_||_"
barcode(49)="||_|___|||_"
barcode(50)="||___|_|||_"
barcode(51)="||_|||_|___"
barcode(52)="||_|||___|_"
barcode(53)="||_|||_|||_"
barcode(54)="|||_|_||___"
barcode(55)="|||_|___||_"
barcode(56)="|||___|_||_"
barcode(57)="|||_||_|___"
barcode(58)="|||_||___|_"
barcode(59)="|||___||_|_"
barcode(60)="|||_||||_|_"
barcode(61)="||__|____|_"
barcode(62)="||||___|_|_"
barcode(63)="|_|__||____"
barcode(64)="|_|____||__"
barcode(65)="|__|_||____"
barcode(66)="|__|____||_"
barcode(67)="|____|_||__"
barcode(68)="|____|__||_"
barcode(69)="|_||__|____"
barcode(70)="|_||____|__"
barcode(71)="|__||_|____"
barcode(72)="|__||____|_"
barcode(73)="|____||_|__"
barcode(74)="|____||__|_"
barcode(75)="||____|__|_"
barcode(76)="||__|_|____"
barcode(77)="||||_|||_|_"
barcode(78)="||____|_|__"
barcode(79)="|___||||_|_"
barcode(80)="|_|__||||__"
barcode(81)="|__|_||||__"
barcode(82)="|__|__||||_"
barcode(83)="|_||||__|__"
barcode(84)="|__||||_|__"
barcode(85)="|__||||__|_"
barcode(86)="||||_|__|__"
barcode(87)="||||__|_|__"
barcode(88)="||||__|__|_"
barcode(89)="||_||_||||_"
barcode(90)="||_||||_||_"
barcode(91)="||||_||_||_"
barcode(92)="|_|_||||___"
barcode(93)="|_|___||||_"
barcode(94)="|___|_||||_"
barcode(95)="|_||||_|___"
barcode(96)="|_||||___|_"
barcode(97)="||||_|_|___"
barcode(98)="||||_|___|_"
barcode(99)="|_|||_||||_"
barcode(100)="|_||||_|||_"
barcode(101)="|||_|_||||_"
barcode(102)="||||_|_|||_"
barcode(103)="||_|____|__"
barcode(104)="||_|__|____"
barcode(105)="||_|__|||__"
barcode(106)="||___|||_|_"
Dim numcode(35)
numcode(0)="|__|||_||__"
numcode(1)="|__|||__||_"
numcode(2)="||__|||__|_"
numcode(3)="||__|_|||__"
numcode(4)="||__|__|||_"
numcode(5)="||_|||__|__"
numcode(6)="||__|||_|__"
numcode(7)="|||_||_|||_"
numcode(8)="|||_|__||__"
numcode(9)="|||__|_||__"

 

numcode(10)="|_|___||___"
numcode(11)="|___|_||___"
numcode(12)="|___|___||_"
numcode(13)="|_||___|___"
numcode(14)="|___||_|___"
numcode(15)="|___||___|_"
numcode(16)="||_|___|___"
numcode(17)="||___|_|___"
numcode(18)="||___|___|_"
numcode(19)="|_||_|||___"
numcode(20)="|_||___|||_"
numcode(21)="|___||_|||_"
numcode(22)="|_|||_||___"
numcode(23)="|_|||___||_"
numcode(24)="|___|||_||_"
numcode(25)="|||_|||_||_"
numcode(26)="||_|___|||_"
numcode(27)="||___|_|||_"
numcode(28)="||_|||_|___"
numcode(29)="||_|||___|_"
numcode(30)="||_|||_|||_"
numcode(31)="|||_|_||___"
numcode(32)="|||_|___||_"
numcode(33)="|||___|_||_"
numcode(34)="|||_||_|___"
numcode(35)="|||_||___|_"

Dim numid(35)
numid(0)=16
numid(1)=17
numid(2)=18
numid(3)=19
numid(4)=20
numid(5)=21
numid(6)=22
numid(7)=23
numid(8)=24
numid(9)=25
numid(10)=33
numid(11)=34
numid(12)=35
numid(13)=36
numid(14)=37
numid(15)=38
numid(16)=39
numid(17)=40
numid(18)=41
numid(19)=42
numid(20)=43
numid(21)=44
numid(22)=45
numid(23)=46
numid(24)=47
numid(25)=48
numid(26)=49
numid(27)=50
numid(28)=51
numid(29)=52
numid(30)=53
numid(31)=54
numid(32)=55
numid(33)=56
numid(34)=57
numid(35)=58
Function gethaxstr(odrid)
dim s
s=odrid

Dim t,i
For i=1 To Len(s)


 ' response.Write "<br >t:"&t&" "
 ' response.Write "<br >i:"&i&" "
 ' response.Write "<br >Mid:"&Mid(s,i,1)
 ' response.Write "<br >numid:"&numid(0)
 'response.Write "<br >LetterToNumber(Mid(s,i,1)):"&LetterToNumber(Mid(s,i,1))
 'response.Write "<br >"
  t=t+(i*numid(LetterToNumber(Mid(s,i,1))))
Next

t=t+103
t=t Mod 103

gethaxstr=t
End Function
Function hascode(odrid)
dim str
str=odrid
str=lcase(str)
str=Replace(str,"0",numcode(0))
str=Replace(str,"1",numcode(1))
str=Replace(str,"2",numcode(2))
str=Replace(str,"3",numcode(3))
str=Replace(str,"4",numcode(4))
str=Replace(str,"5",numcode(5))
str=Replace(str,"6",numcode(6))
str=Replace(str,"7",numcode(7))
str=Replace(str,"8",numcode(8))
str=Replace(str,"9",numcode(9))
str=Replace(str,"a",numcode(10))
str=Replace(str,"b",numcode(11))
str=Replace(str,"c",numcode(12))
str=Replace(str,"d",numcode(13))
str=Replace(str,"e",numcode(14))
str=Replace(str,"f",numcode(15))
str=Replace(str,"g",numcode(16))
str=Replace(str,"h",numcode(17))
str=Replace(str,"i",numcode(18))
str=Replace(str,"j",numcode(19))
str=Replace(str,"k",numcode(20))
str=Replace(str,"l",numcode(21))
str=Replace(str,"m",numcode(22))
str=Replace(str,"n",numcode(23))
str=Replace(str,"o",numcode(24))
str=Replace(str,"p",numcode(25))
str=Replace(str,"q",numcode(26))
str=Replace(str,"r",numcode(27))
str=Replace(str,"s",numcode(28))
str=Replace(str,"t",numcode(29))
str=Replace(str,"u",numcode(30))
str=Replace(str,"v",numcode(31))
str=Replace(str,"w",numcode(32))
str=Replace(str,"x",numcode(33))
str=Replace(str,"y",numcode(34))
str=Replace(str,"z",numcode(35))
str="||_|____|__" & str & barcode(gethaxstr(odrid)) &"||___|||_|_||"
hascode=str
End Function

Function setcolor(odrstr,w)
dim code_H,code_W,c
code_H=50
code_W=w
c = odrstr
c = replace(c,"_","<SPAN STYLE='BACKGROUND-COLOR:#FFFFFF;WIDTH:"&code_w&";HEIGHT:"&code_H&";'></SPAN>")
c = replace(c,"|","<SPAN STYLE='BACKGROUND-COLOR:#000000;WIDTH:"&code_w&";HEIGHT:"&code_H&";'></SPAN>")
setcolor = c
End Function

 '将字母的位置换成数字
function LetterToNumber(Letter)
Letter=lcase(Letter)
dim azStr,azStr2,iii,azStr1,i
azStr="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"
azStr= split(azStr,",")

For i=0 To UBound(azStr)
   'azStr2=Mid(azStr,iii,1)
   'response.Write "<br >azStr("&i&"):"&azStr(i)
   azStr1=azStr(i)
   if azStr(i)  =  Letter then
     azStr2=replace(azStr(i),Letter,i)
   end if
Next
'response.Write azStr2
LetterToNumber=azStr2

End Function

'调用
'response.Write setcolor(hascode("DH5200071112097"),1)
'response.Write setcolor(hascode("DH5200071112097"),2)
'response.Write setcolor(hascode("DH5200071112097"),3)
%>

 

Code128 字符表 用于二次开发用

Code128 字符表:

可以看出从0-63这前64个字符中A类和B类是一样的。

其中有些控制字符,比如CodeA表示此字段下一个个块临时使用Code128A的字符表中的字符。

还有一些其他的,不是很常见,有兴趣的朋友可以参考GBT 15425-2002 EAN UCC系统 128条码 标准。 

 注:ABC分别为128A类,128B类,128C类的字符表。有些B类的字符为空表示和A类的一样。 

B,S,B,S,B,S//

A

B

2,1,2,2,2,2,//

sp

 

0

2,2,2,1,2,2,//

!

 

1

2,2,2,2,2,1,//

"

 

2

1,2,1,2,2,3,//

#

 

3

1,2,1,3,2,2,//

$

 

4

1,3,1,2,2,2,//

%

 

5

1,2,2,2,1,3,//

&

 

6

1,2,2,3,1,2,//

...

 

7

1,3,2,2,1,2,//

(

 

8

2,2,1,2,1,3,//

)

 

9

2,2,1,3,1,2,//

*

 

10

2,3,1,2,1,2,//

+

 

11

1,1,2,2,3,2,//

,

 

12

1,2,2,1,3,2,//

-

 

13

1,2,2,2,3,1,//

.

 

14

1,1,3,2,2,2,//

/

 

15

1,2,3,1,2,2,//

0

 

 

16

 

1,2,3,2,2,1,//

1

 

17

2,2,3,2,1,1,//

2

 

18

2,2,1,1,3,2,//

3

 

19

2,2,1,2,3,1,//

4

 

20

2,1,3,2,1,2,//

5

 

21

2,2,3,1,1,2,//

6

 

22

3,1,2,1,3,1,//

7

 

23

3,1,1,2,2,2,//

8

 

24

3,2,1,1,2,2,//

9

 

25

3,2,1,2,2,1,//

:

 

26

3,1,2,2,1,2,//

;

 

27

3,2,2,1,1,2,//

 

28

3,2,2,2,1,1,//

=

 

29

2,1,2,1,2,3,//

 

30

2,1,2,3,2,1,//

?

 

31

2,3,2,1,2,1,//

@

 

32

1,1,1,3,2,3,//

A

 

33

1,3,1,1,2,3,//

B

 

34

1,3,1,3,2,1,//

C

 

35

1,1,2,3,1,3,//

D

 

36

1,3,2,1,1,3,//

E

 

37

1,3,2,3,1,1,//

F

 

38

2,1,1,3,1,3,//

G

 

39

2,3,1,1,1,3,//

H

 

40

2,3,1,3,1,1,//

I

 

41

1,1,2,1,3,3,//

J

 

42

1,1,2,3,3,1,//

K

 

43

1,3,2,1,3,1,//

L

 

44

1,1,3,1,2,3,//

M

 

45

1,1,3,3,2,1,//

N

 

46

1,3,3,1,2,1,//

O

 

47

3,1,3,1,2,1,//

P

 

48

2,1,1,3,3,1,//

Q

 

49

2,3,1,1,3,1,//

R

 

50

2,1,3,1,1,3,//

S

 

51

2,1,3,3,1,1,//

T

 

52

2,1,3,1,3,1,//

U

 

53

3,1,1,1,2,3,//

V

 

54

3,1,1,3,2,1,//

W

 

55

3,3,1,1,2,1,//

X

 

56

3,1,2,1,1,3,//

Y

 

57

3,1,2,3,1,1,//

Z

 

58

3,3,2,1,1,1,//

[

 

59

3,1,3,1,1,1,//

\

 

60

2,2,1,4,1,1,//

]

 

61

4,3,1,1,1,1,//

^

 

62

1,1,1,2,2,4,//

_

 

63

1,1,1,4,2,2,//

NUL

'

64

1,2,1,1,2,4,//

SOH

a

65

1,2,1,4,2,1,//

STX

b

66

1,4,1,1,2,2,//

ETX

c

67

1,4,1,2,2,1,//

EOT

d

68

1,1,2,2,1,4,//

ENQ

e

69

1,1,2,4,1,2,//

ACK

f

70

1,2,2,1,1,4,//

BEL

g

71

1,2,2,4,1,1,//

BS

h

72

1,4,2,1,1,2,//

HT

i

73

1,4,2,2,1,1,//

LF

j

74

2,4,1,2,1,1,//

VT

k

75

2,2,1,1,1,4,//

FF

l

76

4,1,3,1,1,1,//

CR

m

77

2,4,1,1,1,2,//

SO

n

78

1,3,4,1,1,1,//

SI

o

79

1,1,1,2,4,2,//

DLE

p

80

1,2,1,1,4,2,//

DC1

q

81

1,2,1,2,4,1,//

DC2

r

82

1,1,4,2,1,2,//

DC3

s

83

1,2,4,1,1,2,//

DC4

t

84

1,2,4,2,1,1,//

NAK

u

85

4,1,1,2,1,2,//

SYN

v

86

4,2,1,1,1,2,//

ETB

w

87

4,2,1,2,1,1,//

CAN

x

88

2,1,2,1,3,1,//

EM

y

89

2,1,4,1,2,1,//

SUB

z

90

4,1,2,1,2,1,//

ESC

{

91

1,1,1,1,4,3,//

FS

|

92

1,1,1,3,4,1,//

GS

}

93

1,3,1,1,4,1,//

RS

~

94

1,1,4,1,1,3,//

US       

DEL

95

1,1,4,3,1,1,//

FNC3

FNC3

96

4,1,1,1,1,3,//

FNC2

FNC2

97

4,1,1,3,1,1,//

SHIFT

SHIFT

98

1,1,3,1,4,1,//

CodeC

CodeC

99

1,1,4,1,3,1,//

CodeB

FNC4

CodeB

3,1,1,1,4,1,//

FNC4

CodeA

CodeA

4,1,1,1,3,1,//

FNC1

FNC1

FNC1

2,1,1,4,1,2,//

 

StartA

 

2,1,1,2,1,4,//

 

StartB

 

2,1,1,2,3,2,//

 

StartC

 

2,3,3,1,1,1,2,//

 

 

Stop

    相关文章

评论

发表新评论

此内容将保密,不会被其他人看见。
点击刷新验证码
  • 可用的 UBB 标签:
  • 留言最长字数:1000。