国产探花免费观看_亚洲丰满少妇自慰呻吟_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
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 安丘市| 南皮县| 林西县| 贵州省| 怀柔区| 长阳| 龙岩市| 富锦市| 宜兰县| 高唐县| 娄底市| 攀枝花市| 临沂市| 泾阳县| 庆城县| 南雄市| 黑河市| 洛川县| 松滋市| 崇阳县| 曲阳县| 柘城县| 绥化市| 陕西省| 安宁市| 兴城市| 揭东县| 南通市| 浦城县| 固镇县| 墨脱县| 礼泉县| 晋江市| 开平市| 湖口县| 卢湾区| 岳阳市| 建水县| 永胜县| 扶风县| 永胜县|