欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ASP實現(xiàn)URL編碼

 更新時間:2006年10月27日 00:00:00   作者:  
URL編碼是指為了將信息通過URL進(jìn)行傳輸,所以必須將某些含有特殊意義的字符進(jìn)行替換的一種編碼方式,在asp中我們都知道有一個Server.URLEncode的函數(shù)可以完成這個功能。即: 
  如果有空格就用%20代替,如果有其它字符就用%ASCII代替,如果有漢字等四個字節(jié)的字符,就用兩個%ASCII來代替。不過有時候我們也需要將經(jīng)過這種編碼的字符串進(jìn)行解碼,但asp并沒有提供相關(guān)的函數(shù),這給我們處理問題帶來了一定的麻煩。其實我們只要知道了編碼規(guī)則后,就可以用asp代碼來實現(xiàn)我們自己的URlDecode函數(shù)了。 

  具體實現(xiàn)如下: 

復(fù)制代碼 代碼如下:
function urldecode(encodestr)  
newstr=""  
havechar=false  
lastchar=""  
for i=1 to len(encodestr)  
char_c=mid(encodestr,i,1)  
if char_c="+" then  
newstr=newstr & " "  
elseif char_c="%" then  
next_1_c=mid(encodestr,i+1,2)  
next_1_num=cint("&H" & next_1_c)  

if havechar then  
havechar=false  
newstr=newstr & chr(cint("&H" & lastchar & next_1_c))  
else  
if abs(next_1_num)<=127 then  
newstr=newstr & chr(next_1_num)  
else  
havechar=true  
lastchar=next_1_c  
end if  
end if  
i=i+2  
else  
newstr=newstr & char_c  
end if  

next  
urldecode=newstr  
end function 

相關(guān)文章

最新評論