日期:2014-05-16  浏览次数:20495 次

请教各位大侠帮我把这段JS函数改成ASP?
-----开始------------
function   urldecode(source_url){
var   return_url   =   " ";
var   regex   =   ".:/-_0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
var   tmp   =   " ";
var   newside   =   -1;
for(var   i   =   0;   i   <   source_url.length;   i   ++){
tmp   =   source_url.charAt(i);
newside   =   -1;
newside   =   regex.indexOf(tmp);
if(newside   > =   0){
newside   =   (newside   +   regex.length   -   7)   %   regex.length;
return_url   +=   regex.charAt(newside);
}
else{
return_url   +=   tmp;
}
}
return   return_url;
}
---------结束----------

------解决方案--------------------
<%
function urldecode(source_url)
dim regex , tep , newside
regex = ".:/-_0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ " '要替换的
tep = " "
newside = -1
for i = 0 to len(source_url) - 1 '从0开始的,所以要减一
tmp = mid(source_url , i+1 , 1) '这里算法和JavaScript有点不同
newside = -1 '初始化
newside = instr(regex , tmp) - 1 '这里算法也有点不同
if newside > = 0 then
newside = (newside + len(regex) - 7) mod len(regex)
urldecode = urldecode & mid(regex,newside+1,1)
else
urldecode = urldecode & tmp
end if
next 'exit for
end function
%>