亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

ASP編碼和解碼函數(shù)詳解

 更新時(shí)間:2015年10月08日 10:58:59   投稿:lijiao  
這篇文章主要介紹了ASP編碼和解碼函數(shù)的相關(guān)資料,需要的朋友可以參考下

用ASP開(kāi)發(fā)的時(shí)候遇到一個(gè)解碼問(wèn)題。雖然在ASP中使用Request獲取編碼過(guò)URL字符串會(huì)自動(dòng)解碼,但是Request.BinaryRead(Request.TotalBytes)取得Post數(shù)據(jù)時(shí)卻不會(huì)解碼,所以只能手動(dòng)進(jìn)行解碼。
ASP解碼函數(shù):

Function URLDecode(enStr) 
 dim deStr,strSpecial 
 dim c,i,v 
  deStr=""
  strSpecial="!""#$%&'()*+,.-_/:;<=>?@[/]^`{|}~%"
  for i=1 to len(enStr) 
   c=Mid(enStr,i,1) 
   if c="%" then 
    v=eval("&h"+Mid(enStr,i+1,2)) 
    if inStr(strSpecial,chr(v))>0 then 
     deStr=deStr&chr(v) 
     i=i+2 
    else
     v=eval("&h"+ Mid(enStr,i+1,2) + Mid(enStr,i+4,2)) 
     deStr=deStr & chr(v) 
     i=i+5 
    end if
   else
    if c="+" then 
     deStr=deStr&" "
    else
     deStr=deStr&c 
    end if
   end if
  next 
  URLDecode=deStr 
End function

只是個(gè)人愛(ài)好,自己研究了一下編碼的實(shí)現(xiàn)思路,最后自己寫(xiě)了一個(gè)編碼函數(shù),提供大家參考。注:ASP有內(nèi)置的編碼函數(shù),即是Server.URLEncode。

ASP編碼函數(shù):

private Function URLEncoding(vstrIn) 
  strReturn = ""
  For i = 1 To Len(vstrIn) 
  ThisChr = Mid(vStrIn,i,1) 
  If Abs(Asc(ThisChr)) < &HFF Then 
  strReturn = strReturn & ThisChr 
  Else 
  innerCode = Asc(ThisChr) 
  If innerCode < 0 Then 
  innerCode = innerCode + &H10000 
  End If 
  Hight8 = (innerCode And &HFF00)/ &HFF 
  Low8 = innerCode And &HFF 
  strReturn = strReturn & "%" & Hex(Hight8) & "%" & Hex(Low8) 
  End If 
  Next 
  URLEncoding = strReturn 
End Function

建議大家在中文編碼的時(shí)候,還是使用ASP 內(nèi)置的函數(shù)。雖然上面這個(gè)編碼函數(shù)測(cè)試過(guò)N 遍了,沒(méi)有發(fā)現(xiàn)問(wèn)題,但是以防萬(wàn)一存在Bug。

以上就是關(guān)于ASP編碼和解碼函數(shù),希望對(duì)大家的學(xué)習(xí)有所幫助。

相關(guān)文章

最新評(píng)論