我有以下代码:
var packet = "\xFF\xFF\xFF\xFF";
packet += "\x6D";
packet += "127.0.0.1:" + this.port;
packet += "\x00";
packet += this.name;
packet += "\x00";
packet += this.state;
packet += "\x00";
packet += "stateA";
packet += "\x00";
packet += "sender";
packet += "\x00";
我有var id = 32;
我想得到这样的东西:
...
packet += "\x00";
packet += "sender";
packet += "\x00";
packet += "\x20;
如何将id
数字转换为 HEX 格式,然后将其与packet
?
我已经看到了谷歌,但我还没有找到解决方案。
谢谢你。