if len(str)<>3 then isvalidhex=false:exit function if(str.length!=3)
{
isvalidhex=false//这个isvalidhex是什么东西?如果是函数名字应该改为return true
}
else
{
return
}

解决方案 »

  1.   

    hex(asc(Mid(enStr,4,1))) 
    enStr.charCodeAt(4).toString(16)
      

  2.   

    chr(v)String.fromCharCode(v)
    v=eval("&h"+Mid(enStr,i+1,2)+Mid(enStr,i+4,2))Eval 函数
    计算一个表达式的值并返回结果。在这里实际上就是:eval("&hD5E2")实际上就是把这个16进制字符串转换成为10进制数字!得到的结果是-10782//结果和数字编码有关!(不懂回头看无符号数字和有符号数字的知识)
      

  3.   

    这些函数我都找到了,也试了一下,不成功哟。
    关键是v=eval("&h"+Mid(enStr,i+1,2)+Mid(enStr,i+4,2))
    这个的结果是-10782,JavaScript是怎么算出来的。
    请帮我把这句翻译一下,马上结贴。
      

  4.   

    <SCRIPT LANGUAGE="JavaScript">
    <!--
    enStr = "%D5%E2"alert(parseInt(enStr.substr(1,2)+enStr.substr(4,2),16));
    //-->
    </SCRIPT>
      

  5.   

    <SCRIPT LANGUAGE="vbScript">
    Dim enStr
    enStr = "%D5%E2"str = "&h"+Mid(enStr,2,2)+Mid(enStr,5,2)MsgBox CLNG(str)
    </SCRIPT>
      

  6.   

    <SCRIPT LANGUAGE="JavaScript">
    <!--
    var enStr = "%D5%E2"
    var i=0
    var v=parseInt('0x'+enStr.substr(i+1,2)+enStr.substr(i+4,2))
    if(v>0x8000)//如果首位是1,0x80000是首位是1的最小的2byte的int数字
    {
    v-=0x10000//按有符号数算,这里如果直接alert,javascript会自动转为long来计算
    //你找一下帮助文件就知道了,javascript在需要的时候,会自动转换数据类型
    alert(v)
    //-->
    </SCRIPT>
      

  7.   

    js用的是unicode。而vbs用的是ascii。不一样的。js没法直接得到ascii码,只能先得到unicode然后查表转换。很是麻烦。要用到ascii的地方还是用vb容易。
      

  8.   

    楼上的说的很对,我现在才发现这个转换是不行的,在繁体系统里就会出问题了。我是用下面的脚本来做客户端的URLDecode转换的在简体下是可以,但在客户端为繁体的时候就不行了。真是气人。有没有好的解决办法?分数不够可以再加。
    <script language=vbscript>
    Function URLDecode(enStr)
        dim deStr , c,i,v 
        deStr=""
        for i=1 to len(enStr)
            c=Mid(enStr,i,1)
            if c="%" then
                v=eval("&h"+Mid(enStr,i+1,2))
                if v<128 then
                    deStr=deStr&chr(v)
                    i=i+2
                else
                    if isvalidhex(mid(enstr,i,3)) then
                        if isvalidhex(mid(enstr,i+3,3)) then
                            v=eval("&h"+Mid(enStr,i+1,2)+Mid(enStr,i+4,2))
                            deStr=deStr&chr(v)
                            i=i+5
                        else
                            v=eval("&h"+Mid(enStr,i+1,2)+cstr(hex(asc(Mid(enStr,i+3,1)))))
                            deStr=deStr&chr(v)
                            i=i+3 
                        end if 
                    Else 
                        destr=destr&c
                    end if
                end if
            else
                if c="+" then
                        deStr=deStr&" "
                else
                        deStr=deStr&c
                end if
            end if
        next
        URLDecode=deStr
    End functionFunction isvalidhex(str)
        isvalidhex=true
        str=ucase(str)
        if len(str)<>3 then isvalidhex=false:exit function
        if left(str,1)<>"%" then isvalidhex=false:exit function
        c=mid(str,2,1)
        if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit function
        c=mid(str,3,1)
        if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit function
    End Function
    </script>
      

  9.   

    我现在最需要的就是一个JavaScript版的URLDecode方法,当然是要支持Unicode的。我找了很多,只找到URLEncode的方法。但就是没有URLDecode的方法。
      

  10.   

    百度得到:http://www.delphibbs.com/keylife/iblog_show.asp?xid=9365
    赫赫!为什么不百度一下呢?
      

  11.   

    谢谢楼上的热心,不过你没有解决的我问题,那个UrlEncode我已经在用了。但就是UrlDecode没有。我很早就搜索过了。
      

  12.   

    对应表都给出来了。一个查表问题页已。把数组处理一下反查过来不就decode了。