如你所知,在JS,encodeURIComponent方法是一种常用的编码方法。但由于工作的需要,有必要在ASP使用这种方法,并检查许多数据。没有很好的方法。最后,用下面的方法来解决这个问题。
复制代码代码如下所示:
<
功能aspencodeuricomponent(SSTR)
aspencodeuricomponent = myencodeuricomponent(SSTR)
%>

功能myencodeuricomponent(SSTR){
返回encodeURIComponent(SSTR);
}

<
端功能
%>

附注:uff1a

encodeURIComponent方法
文本字符串被编码为统一资源标识符(URI)的有效组件。

encodeURIComponent(encodeduristring)

的encodeduristring参数必须代表一个组件的URI编码。

解释
encodeURIComponent方法返回一个编码URI。如果你通过编码结果decodeuricomponent,那么最初的字符串将被返回。因为所有的字符编码encodeURIComponent方法,请注意,如果字符串代表一个路径,例如, / / / folder1 folder2 default.html,湿地也将被编码的。这样,它将无效时,编码结果作为请求发送到Web服务器。如果超过一个URI组件包含在一个字符串,使用encodeURI方法编码。