%D4%DA%CF%DF 是什么编码方式, 用什么解码?

wlszl 2007-08-01 01:46:33
我用decodeURI()进行解码,浏览器提示:被解码的URI不是合法的编码,可我在地址栏输入:http://www.google.cn/search?q=%D4%DA%CF%DF 后,马上出现GOOGLE搜索“在线”的页面,可见%D4%DA%CF%DF 解码后应该是“在线”的意思,但用什么来解码呢?
...全文
495 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
hbhbhbhbhb1021 2007-08-01
  • 打赏
  • 举报
回复
应该是不行的,js的内码不是gb码,只有调vbscript实现,上面的方法实质上都是通过vbscript做的
<script language="vbscript" >
Function AnsiCode(vstrIn)
Dim i, strReturn, innerCode, ThisChr
Dim Hight8, Low8
strReturn = ""
For i = 1 To Len(vstrIn)
ThisChr = Mid(vStrIn,i,1)
If Abs(Asc(ThisChr)) < &HFF Then
strReturn = strReturn & ThisChr
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
AnsiCode = strReturn
End Function
Function DeCodeAnsi(s)
Dim i, sTmp, sResult, sTmp1
sResult = ""
For i=1 To Len(s)
If Mid(s,i,1)="%" Then
sTmp = "&H" & Mid(s,i+1,2)
If isNumeric(sTmp) Then
If CInt(sTmp)=0 Then
i = i + 2
ElseIf CInt(sTmp)>0 And CInt(sTmp)<128 Then
sResult = sResult & Chr(sTmp)
i = i + 2
Else
If Mid(s,i+3,1)="%" Then
sTmp1 = "&H" & Mid(s,i+4,2)
If isNumeric(sTmp1) Then
sResult = sResult & Chr(CInt(sTmp)*16*16 + CInt(sTmp1))
i = i + 5
End If
Else
sResult = sResult & Chr(sTmp)
i = i + 2
End If
End If
Else
sResult = sResult & Mid(s,i,1)
End If
Else
sResult = sResult & Mid(s,i,1)
End If
Next
DeCodeAnsi = sResult
End Function

</script>
<script language=javascript>
alert(AnsiCode("在线"))
alert(DeCodeAnsi("%D4%DA%CF%DF"))
</script>
wlszl 2007-08-01
  • 打赏
  • 举报
回复
编码我知道怎么弄,我用的是:
String.prototype.UrlEncode = function()
{
var str = this;
str = str.replace(/./g,function(sHex)
{
window.EnCodeStr = "";
window.sHex = sHex;
window.execScript('window.EnCodeStr=Hex(Asc(window.sHex))',"vbscript");
return window.EnCodeStr.replace(/../g,"%$&");
});
return str;
}

但解码怎么弄,希望高人帮忙,最好是JS的
hbhbhbhbhb1021 2007-08-01
  • 打赏
  • 举报
回复
这是gb码,google主要是还是unicode码,一般手动输入的会被转成unicode码
<script language=vbscript>
msgbox hex(asc("在"))
</script>

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧