<script language="vbscript">
dim str
str="%D6%D0"
msgbox URLDecode(str)
function URLDecode(enStr)
dim deStr,strSpecial
dim c,i,v
deStr=""
strSpecial="!""#$%&'()*+,/:;<=>?@[\]^`{|}~%"
for i=1 to len(enStr)
c=Mid(enStr,i,1)
if c="%" then
v=eval("&h"+Mid(enStr,i+1,2))
if inStr(strSpecial,chr(v))>0 then
deStr=deStr&chr(v)
i=i+2
else
v=eval("&h"+Mid(enStr,i+1,2)+Mid(enStr,i+4,2))
deStr=deStr&chr(v)
i=i+5
end if
else
if c="+" then
deStr=deStr&" "
else
deStr=deStr&c
end if
end if
next
URLDecode=deStr
end function
</script>
dim str
str="%D6%D0"
msgbox URLDecode(str)
function URLDecode(enStr)
dim deStr,strSpecial
dim c,i,v
deStr=""
strSpecial="!""#$%&'()*+,/:;<=>?@[\]^`{|}~%"
for i=1 to len(enStr)
c=Mid(enStr,i,1)
if c="%" then
v=eval("&h"+Mid(enStr,i+1,2))
if inStr(strSpecial,chr(v))>0 then
deStr=deStr&chr(v)
i=i+2
else
v=eval("&h"+Mid(enStr,i+1,2)+Mid(enStr,i+4,2))
deStr=deStr&chr(v)
i=i+5
end if
else
if c="+" then
deStr=deStr&" "
else
deStr=deStr&c
end if
end if
next
URLDecode=deStr
end function
</script>
解决方案 »
- js如何实现这种中英文对照功能?
- 假分页checkbox
- 【WEB开发菜鸟求教1】JS 实现年月的问题~~~
- 奇怪的问题! 关于JAVASCRIPT中 ^ $ 与 / / 声明的正则表达式 用test方法调用的时候 出现奇怪的问题??
- 求助让JQUERY插件每个访问这只执行一次
- document.getElementById("slideShow").filters.revealTrans.Transition在firefox里不认
- for循环问题
- 能把ACTIVEX的事件保存在COOKIE里吗?
- 两个IP是否能够ping通的条件?
- WdatePicker 支持国际化
- 对于一个字符串,里面包含了一些分号,可能是中文,也可能是英文,我怎么用js实现把所有的分号转换为英文分号
- 用简体DW制作繁体或日文出现的问题???
然后用document.location.search得到 %D6%D0%BB%AA%C8%CB%C3%F1 这样一串字符,
但当我用encodeURI("中华人民")时得到 %E4%B8%AD%E5%8D%8E%E4%BA%BA%E6%B0%91 这样一串字符,
显然他们不一样,
<!--
String.prototype.AddZeroPerfix=function (len){
if(this.length>=len)
return this;
var str='0000000000000000000000000000'+this;
return str.substr(str.length-len,len);
}
function URLEncode(str){
var strRet='';
for(var iCnt=0;iCnt<str.length;iCnt++){
if(str.charCodeAt(iCnt)>255){
strRet+='%u'+str.charCodeAt(iCnt).toString(16).toUpperCase().AddZeroPerfix(4);
}else{
strRet+='%'+str.charCodeAt(iCnt).toString(16).toUpperCase().AddZeroPerfix(2);
}
}
return strRet;
}
alert(unescape(URLEncode('中z华w人s民d共f和g国has')));
-->
</script>