As we all know, the encodeURIComponent method is a relatively common encoding method in js. However, due to work needs, this method needs to be used in asp. After checking a lot of information, there is no good method. Finally, I used the following method, which basically solved the problem. problem.
<%
Function aspEncodeURIComponent(sStr)
aspEncodeURIComponent = myEncodeURIComponent(sStr)
%>
<script language="javascript" type="text/javascript" runat="server">
function myEncodeURIComponent(sStr){
return encodeURIComponent(sStr);
}
</script>
<%
End Function
%>
Note:
The encodeURIComponent method encodes a text string into a valid component of a Uniform Resource Identifier (URI).
encodeURIComponent(encodedURIString)
The required encodedURIString parameter represents an encoded URI component.
illustrate
The encodeURIComponent method returns an encoded URI. If you pass the encoding result to decodeURIComponent, the original string will be returned. Because the encodeURIComponent method encodes all characters, please note that if the string represents a path, such as /folder1/folder2/default.html, the slashes in it will also be encoded. As a result, the encoding result will be invalid when sent as a request to the web server. If the string contains more than one URI component, use the encodeURI method to encode it.