欢迎光临
我们一直在努力

ASP中实现的类似URLEncode的编码函数及对应解码函数-ASP教程,ASP技巧

建站超值云服务器,限时71元/月

<%
coding.inc.asp
all rights reserved, room3rd@hotmail.com

function encode(str)
 dim count, pos, ch, code
 dim sweetch
 
 sweetch中表示不需要进行编码的字符
 sweetch = “abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz_{}[]()”
 encode = “”
 
 count = len(str)
 pos = 1
 do while pos<=count
  ch = mid(str, pos, 1)
 
  code = asc(ch)
  if code>=0 and code<256 then  汉字不予处理
   if ch<>”%” then
    if instr(sweetch, ch)=0 then
     ch = “%” & right(“0” & hex(code), 2)
    end if
   else
    ch = “%25”
   end if
  end if
 
  encode = encode & ch
  pos = pos + 1
 loop
end function

function decode(str)
 dim count, pos, ch, code
 
 decode = “”
 
 count = len(str)
 pos = 1
 do while pos<=count
  ch = mid(str, pos, 1)
  if ch=”%” then
   if pos+2<=count then
    ch = chr((instr(“0123456789abcdef”, ucase(mid(str, pos+1, 1)))-1) * 16 + instr(“0123456789abcdef”,ucase(mid(str, pos+2, 1))) – 1)
   else
    编码串不正确
    ch = “”
   end if
   pos = pos + 2
  end if
  decode = decode & ch
  pos = pos + 1
 loop
end function
%>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » ASP中实现的类似URLEncode的编码函数及对应解码函数-ASP教程,ASP技巧
分享到: 更多 (0)