其他分享
首页 > 其他分享> > 16进制字符串转ByteArray(未测)

16进制字符串转ByteArray(未测)

作者:互联网

function onClickBtn2(e:MouseEvent):void{
        var data:String = command_2;
        var bytes:ByteArray = tenToHexFunc(data);
        udp.send(bytes, 0, 0, this.remoteAddress, this.remotePort);
}
//将16进制字符串转化为byteArray
function tenToHexFunc(_info:String):ByteArray{
        _info=_info.split(" ").join("");//删除所有的空格
            
        var byte:ByteArray = new ByteArray();
        for (var i:uint = 0; i < _info.length; i = i + 2)
        {
                //trace(i);
                byte.writeByte(uint("0x" + _info.substr(i, 2)))
                trace(_info.substr(i, 2));
        }
        return byte;
}
function sendHEXFunc(socket:Socket, msg:ByteArray):void{
        socket.writeBytes(msg);
        socket.flush();
}

  http://www.11ria.com/forum.php?mod=viewthread&tid=154&page=4#pid32389

标签:ByteArray,info,socket,16,function,未测,var,byte
来源: https://www.cnblogs.com/dt1991/p/15146888.html