ASP讓url的中文顯示為編碼
更新時(shí)間:2011年02月27日 15:26:33 作者:
有時(shí)候傳遞中文會(huì)出現(xiàn)亂碼等原因,最好對中文參數(shù)進(jìn)行編碼處理。
asp解碼url
<a href="1.asp?action=<%=server.urlencode("你好")%>">asdf</a>
解碼函數(shù)
[code]
<%
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
response.Write URLDecode(request.QueryString("action"))
%>
[html]
復(fù)制代碼 代碼如下:
<a href="1.asp?action=<%=server.urlencode("你好")%>">asdf</a>
解碼函數(shù)
[code]
<%
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
response.Write URLDecode(request.QueryString("action"))
%>
[html]
相關(guān)文章
ASP XMLDom在服務(wù)器端操作XML文件的主要方法和實(shí)現(xiàn)
我曾經(jīng)測試過不用數(shù)據(jù)庫,把網(wǎng)站的會(huì)員信息,商品數(shù)據(jù)信息,交易信息,網(wǎng)站定制信息全部存放在三個(gè)xml文件中,運(yùn)行結(jié)果十分正常,感覺上比數(shù)據(jù)庫快多了,不過沒有作測試,不能確定。2010-02-02
asp中獲取當(dāng)前月份距離以前某個(gè)時(shí)間的月份數(shù)
獲取當(dāng)前月份距離以前某個(gè)時(shí)間的月份數(shù),asp都是用DateDiff函數(shù)來實(shí)現(xiàn)2012-04-04
asp+JMAIL實(shí)現(xiàn)發(fā)送郵件
這篇文章主要介紹了asp+JMAIL實(shí)現(xiàn)發(fā)送郵件實(shí)例代碼,感興趣的小伙伴們可以參考一下2015-09-09
ASP 遞歸調(diào)用 已知節(jié)點(diǎn)查找根節(jié)點(diǎn)的函數(shù)
已知節(jié)點(diǎn)查找根節(jié)點(diǎn)的asp函數(shù)2009-12-12

