You know, in JS encodeURIComponent method is a more commonly used encoding method, but due to the work needs, in the ASP need to this method, check a lot of information, there is no good method, and finally used the following method, the basic solution to the problem.
Copy Code code as follows:
<%
Function aspencodeuricomponent (SSTR)
Aspencodeuricomponent = Myencodeuricomponent (SSTR)
%>
<script language= "javascript" type= "Text/javascript" runat= "Server" >
function Myencodeuricomponent (SSTR) {
Return encodeURIComponent (SSTR);
}
</script>
<%
End Function
%>
Note:
encodeURIComponent method
Encodes a text string as a valid component of a Uniform Resource Identifier (URI).
encodeURIComponent (encodeduristring)
The required encodeduristring parameter represents an encoded URI component.
Description
The encodeURIComponent method returns an encoded URI. If you pass the encoding result to decodeURIComponent, the original string is returned. Because the encodeURIComponent method encodes all characters, note that if the string represents a path, such as/folder1/folder2/default.html, the slash will also be encoded. This will not be valid when the encoding result is sent as a request to the Web server. If the string contains more than one URI component, use the encodeURI method to encode it.