国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

ASP中只有UrlEncode,沒有Urldecode問題的解決方法?

2024-05-04 10:59:27
字體:
來源:轉載
供稿:網友

在ASP中傳遞參數時有一個很有用的系統函數Server.UrlEncode,可以將一些非字母數字的特殊符號轉換成標準URL編碼(其實就是16進制ASC碼),這樣就解決了參數傳遞問題,然后我以為也提供了Server.UrlDecode,但使用后卻發現程序報錯,原來系統并沒有提供這個我想象中的解碼函數。怎幺辦,自己動手吧。

UrlEncode的原理其實很簡單,就是將特殊字符轉換成16進制ASC碼值,那么譯碼函數就只要將16進制ASC轉回對應的字符就OK了。

Function URLDecode(enStr)          'URL解碼函數  dim deStr  dim c,i,v  deStr=""  for i=1 to len(enStr)    c=Mid(enStr,i,1)    if c="%" then      v=eval("&h"+Mid(enStr,i+1,2))      if v<128 then        deStr=deStr&chr(v)        i=i+2      else        if isvalidhex(mid(enstr,i,3)) then          if isvalidhex(mid(enstr,i+3,3)) then            v=eval("&h"+Mid(enStr,i+1,2)+Mid(enStr,i+4,2))            deStr=deStr&chr(v)            i=i+5          else            v=eval("&h"+Mid(enStr,i+1,2)+cstr(hex(asc(Mid(enStr,i+3,1)))))            deStr=deStr&chr(v)            i=i+3          end if        else          destr=destr&c        end if      end if    else      if c="+" then        deStr=deStr&" "      else        deStr=deStr&c      end if    end if  next  URLDecode=deStr end function  function isvalidhex(str)  isvalidhex=true  str=ucase(str)  if len(str)<>3 then isvalidhex=false:exit function  if left(str,1)<>"%" then isvalidhex=false:exit function  c=mid(str,2,1)  if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit function  c=mid(str,3,1)  if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit function end function

經測試gb312格式的asp使用沒有問題。

您可能感興趣的文章:

ASP中實現的URLEncode、URLDecode自定義函數ASP的URLDecode函數URLEncode解碼函數用ASP應用程序實現自己的UrlDeCode
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 汕尾市| 读书| 辽源市| 全椒县| 惠州市| 枞阳县| 突泉县| 舒兰市| 溆浦县| 墨竹工卡县| 鹤壁市| 耒阳市| 海原县| 怀来县| 昔阳县| 双辽市| 淳安县| 灵山县| 鄄城县| 大丰市| 无为县| 崇礼县| 新津县| 准格尔旗| 沙坪坝区| 景泰县| 百色市| 禹州市| 舒城县| 东台市| 桦川县| 石楼县| 长阳| 新宾| 乡城县| 宜兴市| 商洛市| 乌拉特中旗| 定日县| 屏山县| 新田县|