%CC%AB%C6%BD%D1%F3 应该 显示 为“太平洋” 现在显示 :̫ƽÑó

解决方案 »

  1.   

    <script language="vbscript" > 
      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>
    var str="%CC%AB%C6%BD%D1%F3"
    execScript("str=DeCodeAnsi('"+str+"')","VBScript");
    alert(str)
    </script>
      

  2.   

    怎么不能显示出来了?帮我看下是什么问题,以下代码是放在JS文件里的,VBSCRIPT放在页面里面。function getQuery(name)
    {
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = location.search.substr(1).match(reg);
        if (r!=null) return unescape(r[2]); return null;
    }function popsearch(){
    var bid=getQuery("bid");
    var key=escape(getQuery("key"));  //加入的
    execScript("key=DeCodeAnsi(\'"+key+"\')","VBScript"); //加入的
    if (bid=="video"){
    document.writeln("<form action=\"/videoSearch.asp\" method=\"get\" name=\"form1\">");
    }
    else
    {
    document.writeln("<form action=\"/s.asp\" method=\"get\" name=\"form1\">");
    }
    document.writeln("<div id=\"forinput\"><input id=\"key\" name=\"key\" maxlength=\"100\"/ value=\""+key+"\" style=\"width:280px;\"><iput type=\"hidden\" value=\""+bid+"\"> <input id=\"searchsubmit\"");
    document.writeln("type=\"submit\" value=\"搜&nbsp;索\"/><br />");
    document.writeln("</div></form></div>");
    //-->
    }
      

  3.   

    FIRE FOX 里面不能显示,IE显示的还是乱码
      

  4.   

    注意执行顺序,vbscript要在调用之前加载
      

  5.   

    <script language="vbscript" >
    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>
    function getQuery(name)
    {
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = location.search.substr(1).match(reg);
        if (r!=null) return unescape(r[2]); return null;
    }
    var key=getQuery("key")
    execScript("str=DeCodeAnsi('"+str+"')","VBScript");
    document.writeln(str);</script>aa.html?key=%BA%BC%D6%DD%B2%A1%C8%CB就是这样也不行啊
      

  6.   

    <script language="vbscript" >
    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>
    function getQuery(name)
    {
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = location.search.substr(1).match(reg);
        if (r!=null) return unescape(r[2]); return null;
    }
    var key=getQuery("key")
    execScript("key=DeCodeAnsi('"+key+"')","VBScript");
    document.writeln(key);</script>还是乱码,FIREFOX是不是不支持execScript啊?怎么乱码也显示不了?
      

  7.   

    这个最好用服务器端来解决,百度的URL编码就是GB码