ASP讓url的中文顯示為編碼
更新時(shí)間:2011年02月27日 15:26:33 作者:
有時(shí)候傳遞中文會(huì)出現(xiàn)亂碼等原因,最好對(duì)中文參數(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的SQL語(yǔ)句中and和or同時(shí)使用的注意事項(xiàng)
這篇文章主要介紹了asp的SQL語(yǔ)句中and和or同時(shí)使用的注意事項(xiàng),需要的朋友可以參考下2015-11-11四步完成asp網(wǎng)頁(yè)設(shè)計(jì)流量統(tǒng)計(jì)
這篇文章主要介紹了四步如何完成asp網(wǎng)頁(yè)設(shè)計(jì)流量統(tǒng)計(jì),感興趣的小伙伴可以參考一下2015-09-09flash和asp分頁(yè)的一點(diǎn)心得與flash腳本
flash和asp分頁(yè)的一點(diǎn)心得與flash腳本...2007-03-03解決使用良精企業(yè)建站7.0未注冊(cè)問(wèn)題
解決使用良精企業(yè)建站7.0未注冊(cè)問(wèn)題...2007-04-04Asp Conn.execute的參數(shù)與返回值總結(jié)
這篇文章主要介紹了Asp Conn.execute的參數(shù)與返回值總結(jié),數(shù)據(jù)庫(kù)對(duì)象的execute方法參數(shù)與返回值總結(jié),需要的朋友可以參考下2014-07-07asp有效防止網(wǎng)站留言板出現(xiàn)垃圾留言/評(píng)論實(shí)現(xiàn)思路
如何有效防止網(wǎng)站(留言板)出現(xiàn)垃圾留言,垃圾評(píng)論?本文提供詳細(xì)解決思路與實(shí)現(xiàn)步驟,需要了解的朋友可以參考下2012-12-12