没辄呀,JS对二进制流的处理无能为力。

解决方案 »

  1.   

    <script>
    <!--
    var temp="慢讬憂慢憂"/*0x61628bac618261626182:ab讬a艡ba 
    解析结果:0x61(a)62(b)8bac(讬)61(a)8261(艡)62(b)61(a)
    82(最后一个,无法配为Unicode字符,0x82为空字符,没有显示出来
    仔细注意一下,最后的字符a后边还有一个空格,那就是0x82了)*/
    document.write(B2Str(temp))
    function B2Str(obj)
    {
        var returnVal=""
        var Bytes=toBytes(obj)
        for(var i=0;i<Bytes.length;i++)
        {
            if(Bytes[i]<0x80||i==Bytes.length)
            {
                returnVal+=String.fromCharCode(Bytes[i])
            }
            else
            {
                returnVal+=String.fromCharCode((Bytes[i]<<8)+Bytes[i+1])
                i++
            }
        }
        return returnVal
    }
    function toBytes(obj)
    {
        var my_array = new Array()
        for(var i=0;i<obj.length;i++)
        {
            var temp=obj.charCodeAt(i)
            my_array[2*i]=temp>>8
            my_array[2*i+1]=temp-(temp>>8<<8)
        }
        return my_array
    }
    -->
    </script>
      

  2.   

    上边是我的代码很想知道搂住从哪儿来的二进制流?我不知道该怎么办,只好写了个奇怪的字符串来模拟二进制流!