找回密码
 立即注册
gethexvFunctionThisCodeCASE | 软件设计/软件工程 2022-05-02 238 0star收藏 版权: . 保留作者信息 . 禁止商业使用 . 禁止修改作品
'根据tag获取con的左边字符串
Function GetLeftPart(Con, tag)
  if instr(con,tag)>0 then
    GetLeftPart = Left(Con, InStr(Con, tag) - 1)
  else
    GetLeftPart = ""
  end if
End Function

'根据tag1和tag2获取con的中间字符串
Function GetBetweenPart(Con, tag1, tag2)
  if instr(con,tag1)>0 and instr(con,tag2)>0 then
    GetBetweenPart = GetLeftPart(GetRightPart(Con, tag1), tag2)
  else
    GetBetweenPart = ""
  end if
End Function

'根据标签获取正确的con字符串
Function GetRightPart(Con, tag)
  if instr(con,tag)>0 then
    GetRightPart = Right(Con, Len(Con) - InStr(Con, tag) - Len(tag) + 1)
  else
    GetRightPart = ""
  end if
End Function

'-----------------字符Unicode编码和反向编码----------
Function CodeToUni(code)
  dim ix,thisStr,ThisCode,newcode
  
  if code="" then
     codetouni=""
     exit function
  end if   
  
  for ix=1 to len(code)
    thisstr=right(left(code,ix),1)
    thiscode=hex(ascw(thisstr))
    if len(thiscode)=1 then
       thiscode="000"+thiscode
    elseif len(thiscode)=2 then
       thiscode="00"+thiscode  
    elseif len(thiscode)=3 then
       thiscode="0"+thiscode  
    end if
    newcode=newcode+thiscode
  next
   
  codetouni=newcode
      
End Function

Function UniToCode(unic)
  dim ixx,thisUni,oricode,fst,sec,trd,fth,oristr
  
  if unic="" then
     unitocode=""
     exit function
  end if
     
  for ixx=1 to len(unic)/4
    thisuni=right(left(unic,ixx*4),4)  
    if left(thisuni,2)="00" then
       thisuni=right(thisuni,2)
       fst=gethexv(right(thisuni,1))
       sec=gethexv(left(thisuni,1))
       oricode=chr(sec*16+fst)
       oristr=oristr+oricode
    else   
       fst=gethexv(right(thisuni,1))
       sec=gethexv(right(left(thisuni,3),1))
       trd=gethexv(right(left(thisuni,2),1))
       fth=gethexv(left(thisuni,1))
       oricode=chrw(fth*16*16*16+trd*16*16+sec*16+fst)
       oristr=oristr+oricode
    end if     
  next
   
  unitocode=oristr
     
End Function

Function GetHexV(ST)
  
  SELECT CASE ST
  CASE "0"
     GETHEXV=0
  CASE "1"
     GETHEXV=1   
  CASE "2"
     GETHEXV=2
  CASE "3"
     GETHEXV=3
  CASE "4"
     GETHEXV=4
  CASE "5"
     GETHEXV=5   
  CASE "6"
     GETHEXV=6
  CASE "7"
     GETHEXV=7   
  CASE "8"
     GETHEXV=8
  CASE "9"
     GETHEXV=9   
  CASE "A"
     GETHEXV=10
  CASE "B"
     GETHEXV=11
  CASE "C"
     GETHEXV=12
  CASE "D"
     GETHEXV=13   
  CASE "E"
     GETHEXV=14
  CASE "F"
     GETHEXV=15      
  END SELECT
     
End Function

('get the left string of con according to tag
Function GetLeftPart(Con, tag)
if instr(con,tag)>0 then
GetLeftPart = Left(Con, InStr(Con, tag) - 1)
else
GetLeftPart = ""
end if
End Function
'get the intermediate string of con according to tag1 and tag2
Function GetBetweenPart(Con, tag1, tag2)
if instr(con,tag1)>0 and instr(con,tag2)>0 then
GetBetweenPart = GetLeftPart(GetRightPart(Con, tag1), tag2)
else
GetBetweenPart = ""
end if
End Function
'get the correct con string according to the label
Function GetRightPart(Con, tag)
if instr(con,tag)>0 then
GetRightPart = Right(Con, Len(Con) - InStr(Con, tag) - Len(tag) + 1)
else
GetRightPart = ""
end if
End Function
'------------------ Unicode encoding and reverse encoding of characters----------
Function CodeToUni(code)
dim ix,thisStr,ThisCode,newcode
if code="" then
codetouni=""
exit function
end if   
for ix=1 to len(code)
thisstr=right(left(code,ix),1)
thiscode=hex(ascw(thisstr))
if len(thiscode)=1 then
thiscode="000"+thiscode
elseif len(thiscode)=2 then
thiscode="00"+thiscode  
elseif len(thiscode)=3 then
thiscode="0"+thiscode  
end if
newcode=newcode+thiscode
next
codetouni=newcode
End Function
Function UniToCode(unic)
dim ixx,thisUni,oricode,fst,sec,trd,fth,oristr
if unic="" then
unitocode=""
exit function
end if
for ixx=1 to len(unic)/4
thisuni=right(left(unic,ixx*4),4)  
if left(thisuni,2)="00" then
thisuni=right(thisuni,2)
fst=gethexv(right(thisuni,1))
sec=gethexv(left(thisuni,1))
oricode=chr(sec*16+fst)
oristr=oristr+oricode
else   
fst=gethexv(right(thisuni,1))
sec=gethexv(right(left(thisuni,3),1))
trd=gethexv(right(left(thisuni,2),1))
fth=gethexv(left(thisuni,1))
oricode=chrw(fth*16*16*16+trd*16*16+sec*16+fst)
oristr=oristr+oricode
end if     
next
unitocode=oristr
End Function
Function GetHexV(ST)
SELECT CASE ST
CASE "0"
GETHEXV=0
CASE "1"
GETHEXV=1   
CASE "2"
GETHEXV=2
CASE "3"
GETHEXV=3
CASE "4"
GETHEXV=4
CASE "5"
GETHEXV=5   
CASE "6"
GETHEXV=6
CASE "7"
GETHEXV=7   
CASE "8"
GETHEXV=8
CASE "9"
GETHEXV=9   
CASE "A"
GETHEXV=10
CASE "B"
GETHEXV=11
CASE "C"
GETHEXV=12
CASE "D"
GETHEXV=13   
CASE "E"
GETHEXV=14
CASE "F"
GETHEXV=15      
END SELECT
End Function
)





上一篇:LINUX下SHELL显示-BASH-4.1$不显示路径的解决方法
下一篇:设计模式阅读笔记-----代理模式