?? eancreate.txt
字號:
EAN條碼字體的解碼算法
經常發現用PB的開發人員在問為什么用EAN的字體打出來的條碼掃描槍無法掃描
其實受EAN的編碼規格的限制,EAN的字體是不能直接使用的,EAN13的編碼規格就不
多說了,下面給出兩個函數可把條碼轉換為EAN字體可識別的字符串(分別對應EAN13和EAN8兩種編碼)
對應的字體與PB的DEMO可到下面的地址下載:
http://kivens.nease.net/ean.rar
function string f_GetEAN13FontStr (string as_ean13code);//ENA13
//by kivens.jiang(kivens@china.com) 2005-03-01
string ls_LeftBlankStr="#$%&'()*+,"
string ls_LeftCode[9]={'112122','112212','112221','121122','122112','122211','121212','121221','122121'}
string ls_LeftEanStr='0123456789ABCDEFGHIJ'
string ls_RightEanStr='abcdefghij'
string ls_SplitStr='!'
string ls_MidStr='-'
if len(as_EAN13Code)<>13 then return ''
Integer i,li_index,li_LeftCode,li_Temp_Code
string ls_Result
li_LeftCode=Integer(Left(as_EAN13Code,1))
ls_Result=Mid(ls_LeftBlankStr,li_LeftCode + 1,1)
for i=2 to 13
li_Temp_Code=Integer(mid(as_EAN13Code,i,1)) + 1
if i>7 then
ls_Result=ls_Result+mid(ls_RightEanStr,li_Temp_Code,1)
else
ls_Result=ls_Result+mid(ls_LeftEanStr,li_Temp_Code + (Integer(Mid(ls_LeftCode[li_LeftCode],i - 1,1)) - 1)*10,1)
end if
next
ls_Result=Left(ls_Result,1)+ls_SplitStr+Mid(ls_Result,2,6)+ls_MidStr+Right(ls_Result,6)+ls_SplitStr
return ls_Result
end function
function string f_GetEAN8FontStr (string as_ean13code);//EAN8
//by kivens.jiang(kivens@china.com) 2005-03-01
string ls_LeftBlankStr="#$%&'()*+,"
string ls_LeftCode[9]={'112122','112212','112221','121122','122112','122211','121212','121221','122121'}
string ls_LeftEanStr='0123456789ABCDEFGHIJ'
string ls_RightEanStr='abcdefghij'
string ls_SplitStr='!'
string ls_MidStr='-'
if len(as_EAN13Code)<>8 then return ''
Integer i,li_index,li_LeftCode,li_Temp_Code
string ls_Result
li_LeftCode=Integer(Left(as_EAN13Code,1))
for i=1 to 8
li_Temp_Code=Integer(mid(as_EAN13Code,i,1)) + 1
if i>4 then
ls_Result=ls_Result+mid(ls_RightEanStr,li_Temp_Code,1)
else
ls_Result=ls_Result+mid(ls_LeftEanStr,li_Temp_Code + (Integer(Mid(ls_LeftCode[li_LeftCode],i - 1,1)) - 1)*10,1)
end if
next
ls_Result=ls_SplitStr+Mid(ls_Result,1,4)+ls_MidStr+Right(ls_Result,4)+ls_SplitStr
return ls_Result
end function
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -