永发信息网

如何用VB实现URL编码与解码

答案:1  悬赏:30  手机版
解决时间 2021-01-02 09:19
  • 提问者网友:半生酒醒
  • 2021-01-02 03:34
如何用VB实现URL编码与解码
最佳答案
  • 五星知识达人网友:从此江山别
  • 2021-01-02 04:14
function URLEncode(nstr)
   For i = 1 To Len(nstr)
      nmid=Mid(nstr, i, 1)
      nasc=Asc(nmid)
      if nasc < 0 Then
         nhex=right("000" & Hex(nasc),4)
         URLEncode = URLEncode & "%" & Left(nhex, 2) & "%" & Right(nhex, 2)
      elseif nmid=" " then
         URLEncode = URLEncode & "+"
      Elseif (nasc >= 48 And nasc <= 57) Or (nasc >= 65 And nasc <= 90) Or (nasc >= 97 And nasc <= 122) Then
         URLEncode = URLEncode & nmid
      Else
         URLEncode = URLEncode & "%" & right("0" & Hex(nasc),2)
      End if
   Next
end function
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯