以十六进制输出字节数组

时间:2022-12-26 23:57:34

I have a stream of bytes in my Ruby-script and I'd like to output the values to the console.

我的Ruby脚本中有一个字节流,我想将值输出到控制台。

1 个解决方案

#1


15  

If you read your stream in chunks of bytes, then you could use String#unpack:

如果你用大块的字节读取你的流,那么你可以使用String#unpack:

while buffer = io.read
  str << buffer.unpack('H*')
end

#1


15  

If you read your stream in chunks of bytes, then you could use String#unpack:

如果你用大块的字节读取你的流,那么你可以使用String#unpack:

while buffer = io.read
  str << buffer.unpack('H*')
end