ASP 字符处理

'根据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

'根据tag获取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

'----------------------------------------------

 

转载于:https://www.cnblogs.com/lichsky/p/3308332.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值