javascript不行,因为走unicode<script language=vbs>
function urldecoding(vstrin)
'qiushuiwuhen(2002-6-19)
dim i,strreturn,strSpecial
strSpecial = " <>""#%{}|^[]`&?+"
strreturn = ""
for i = 1 to len(vstrin)
thischr = mid(vstrin,i,1)
if thischr="%" then
intasc=eval("&h"+mid(vstrin,i+1,2))
if instr(strSpecial,chr(intasc))>0 then
strreturn= strreturn & chr(intasc)
i=i+2
else
intasc=eval("&h"+mid(vstrin,i+1,2)+mid(vstrin,i+4,2))
strreturn= strreturn & chr(intasc)
i=i+5
end if
else
strreturn= strreturn & thischr
end if
next
urldecoding = strreturn
end function
function urlencoding(vstrin)
dim i,strreturn,strSpecial
strSpecial = " <>""#%{}|^[]`&?+"
strreturn = ""
for i = 1 to len(vstrin)
thischr = mid(vstrin,i,1)
if abs(asc(thischr)) < &hff then
if instr(strSpecial,thischr)>0 then
strreturn = strreturn & "%" & hex(asc(thischr))
else
strreturn = strreturn & thischr
end if
else
innercode = asc(thischr)
if innercode < 0 then
innercode = innercode + &h10000
end if
hight8 = (innercode and &hff00)\ &hff
low8 = innercode and &hff
strreturn = strreturn & "%" & hex(hight8) & "%" & hex(low8)
end if
next
urlencoding = strreturn
end function
str="恭喜你翻译出正确的字符串"
strEncode=urlencoding(str)
strDecode=urldecoding(strEncode)
document.write str,"=>",strEncode,"=>",strDecode
</script>
function urldecoding(vstrin)
'qiushuiwuhen(2002-6-19)
dim i,strreturn,strSpecial
strSpecial = " <>""#%{}|^[]`&?+"
strreturn = ""
for i = 1 to len(vstrin)
thischr = mid(vstrin,i,1)
if thischr="%" then
intasc=eval("&h"+mid(vstrin,i+1,2))
if instr(strSpecial,chr(intasc))>0 then
strreturn= strreturn & chr(intasc)
i=i+2
else
intasc=eval("&h"+mid(vstrin,i+1,2)+mid(vstrin,i+4,2))
strreturn= strreturn & chr(intasc)
i=i+5
end if
else
strreturn= strreturn & thischr
end if
next
urldecoding = strreturn
end function
function urlencoding(vstrin)
dim i,strreturn,strSpecial
strSpecial = " <>""#%{}|^[]`&?+"
strreturn = ""
for i = 1 to len(vstrin)
thischr = mid(vstrin,i,1)
if abs(asc(thischr)) < &hff then
if instr(strSpecial,thischr)>0 then
strreturn = strreturn & "%" & hex(asc(thischr))
else
strreturn = strreturn & thischr
end if
else
innercode = asc(thischr)
if innercode < 0 then
innercode = innercode + &h10000
end if
hight8 = (innercode and &hff00)\ &hff
low8 = innercode and &hff
strreturn = strreturn & "%" & hex(hight8) & "%" & hex(low8)
end if
next
urlencoding = strreturn
end function
str="恭喜你翻译出正确的字符串"
strEncode=urlencoding(str)
strDecode=urldecoding(strEncode)
document.write str,"=>",strEncode,"=>",strDecode
</script>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货