int转bytes
请问怎么将97转成’\x00\x61’以便向socket传输?
4 回复
charCodeAt
@dlutwuwei 能否具体点?
数字转为字符16进制?感觉有点不对啊,那不是变长了?
console.log("\\x00\\x%s", (97).toString(16))
var x = new Buffer(2); x.writeUInt16BE(97)
请问怎么将97转成’\x00\x61’以便向socket传输?
charCodeAt
@dlutwuwei 能否具体点?
数字转为字符16进制?感觉有点不对啊,那不是变长了?
console.log("\\x00\\x%s", (97).toString(16))
var x = new Buffer(2); x.writeUInt16BE(97)