ASP Encode/Decode Functions
http://www.aspnut.com/reference/encoding.asp
Server.URLEncode
Used for encoding data that will be passed via a querystring variable. A querystring variable is anything following the question mark (?) in the URL (location) field of your browser. You create querystring variables when you perform a redirect or build a hyperlink to another page on your site.
<a href="page2.asp?name=Joe+Schmoe">here</a>
<%
Response.Redirect "page2.asp?ID=3"
%>
In the example above, the hyperlink contains a variable named "name" which has a value of "Joe Schmoe" (the space is encoded as "+") In the Response.Redirect statement, we have a querystring variabled named "ID" with a value of 3. To perform a URL encode on a variable (for purposes of passing this variable to another page) use the following:
<a href="page2.asp?name=<%= Server.URLEncode(sName) %>">
here</a>
<%
Response.Redirect "page2.asp?ID=" &_
Server.URLEncode(nID)
%>
URLDecode
For some reason, Microsoft did not include a URL decode function with Active Server Pages. Most likely, this was because the decoding of querystring variables is done automatically for you when you access the querystring object:
<%= Request.QueryString("name") %>
For those of you who are desperately in need of this function:
' -----------------------------------------
' URL decode to retrieve the original value
Function URLDecode(sConvert)
Dim aSplit
Dim sOutput
Dim I
If IsNull(sConvert) Then
URLDecode = ""
Exit Function
End If
' convert all pluses to spaces
sOutput = REPLACE(sConvert, "+", " ")
' next convert %hexdigits to the character
aSplit = Split(sOutput, "%")
If IsArray(aSplit) Then
sOutput = aSplit(0)
For I = 0 to UBound(aSplit) - 1
sOutput = sOutput & _
Chr("&H" & Left(aSplit(i + 1), 2)) &_
Right(aSplit(i + 1), Len(aSplit(i + 1)) -
Ïà¹ØÎĵµ£º
ΪʲôÔÚASPÀïÖ¸¶¨ÁËcodepageΪ65001»¹¾³£ÏÔʾÂÒÂë¡£²Å×ÓÔÚÕâÀォÕâ¸öÎÊÌâÏêϸ½âÊÍһϣ¬ÒÔÃâºÜ¶àÅóÓÑÔÙ×ßÍä·£¬ÉõÖÁÅųâUTF-8¡£ CHINAZ
¡¡¡¡Èç¹ûÄ㻹²»ÖªµÀUTF-8ÊÇʲô¶«¶«£¬ÄDzÅ×Ó½¨ÒéÄãÏÈÈ¥ËÑË÷Ò»ÏÂUTF-8µÄÏà¹Ø×ÊÁϰɡ£
¡¡¡¡UTF-8±àÂëÖ®ËùÒÔ±»Ô½À´Ô½¶àµÄÈ˽ÓÊÜÉõÖÁϲ»¶£¬¿Ï¶¨ÊÇÓеÀÀíµÄ£¬ÔÚWEB2.0Ê¢ÐеĽñÌ죬ÔÚ´ó̸ ......
<!--#include file="conn.asp" -->
<!--#include file="Fun.asp" -->
<%
'·¢ËÍÓʼþÀà
class SendEmails
'·¢ËÍ
private flag
private info
public sub Class_Initialize()
flag=false
info=""
end sub
public sub Class_Terminate()
flag=false
info=""
......
·½·¨Ò»£º¼òµ¥£¬µÃ²»µ½²ÎÊý£¬Ö»ÓÐÒ»¸öÐéÄâ·¾¶
GetUrl =request("url")
ÀýÈ磺http://127.0.0.1/shiyan.asp?dfsdfsf=dsfsdfd&aa=dddd
»ñȡΪ:shiyan.asp
·½·¨¶þ£ºµÃµ½Õû¸öURL£¬µÃµ½²ÎÊý
'µÃµ½µ±Ç°Ò³ÃæµÄµØÖ·
Function GetUrl()
On Er ......
Èç¹ûÓû§Ê¹ÓõÄä¯ÀÀÆ÷Ö§³Ö¶¯Ì¬ HTML (DHTML)£¬Ôò ASP.NET ÑéÖ¤¿Ø¼þ¿ÉÒÔʹÓÿͻ§¶Ë½Å±¾À´Ö´ÐÐÑéÖ¤¡£ÒòΪÕâÖֿؼþ¿ÉÒÔÌṩ¼°Ê±·´À¡£¨ÎÞÐèµ½·þÎñÆ÷µÄÍù·µ¹ý³Ì£©£¬ËùÒÔÓû§»á¸Ð¾õµ½Ò³µÄÐÔÄÜÓÐËù¸ÄÉÆ¡£
ÔÚ´ó¶àÊýÇé¿öÏ£¬ÎÞÐè¶ÔÒ³»òÑéÖ¤¿Ø¼þ×÷³öÈκθü¸Ä±ã¿ÉʹÓÿͻ§¶ËÑéÖ¤¡£¿Ø¼þ½«×Ô¶¯¼ì²âä¯À ......
ͨ¹ýʹÓÃÑéÖ¤¿Ø¼þ£¬¿ÉÒÔÏò ASP.NET ÍøÒ³ÖÐÌí¼ÓÊäÈëÑéÖ¤¡£ÑéÖ¤¿Ø¼þΪËùÓг£Óõıê×¼ÑéÖ¤ÀàÐÍ£¨ÀýÈ磬²âÊÔij·¶Î§ÄÚµÄÓÐЧÈÕÆÚ»òÖµ£©ÌṩÁËÒ»ÖÖÒ×ÓÚʹÓõĻúÖÆ£¬ÒÔ¼°×Ô¶¨Òå±àдÑéÖ¤µÄ·½·¨¡£´ËÍ⣬ÑéÖ¤¿Ø¼þ»¹ÔÊÐí×Ô¶¨ÒåÏòÓû§ÏÔʾ´íÎóÐÅÏ¢µÄ·½·¨¡£ÑéÖ¤¿Ø¼þ¿ÉÓë ASP.NET ÍøÒ³ÉϵÄÈκοؼ ......