I’m new in Ruby. So, my question can seem simple for you. I need to
generate a hex string from some digits: 1, 114, 3, 2 for example. I need
the following hex representation: 00010072030002 - (0x0001, 0x0072,
0x03, 0x0002).
I tried to use pack:
a = [1, 114, 3, 2]
hexStr = a.pack(‘iisi’)
but it generate following string: 10007200302000
Also, what is the best way to convert this hex string into digits back?
On Jun 17, 2006, at 20:52, Michael stepanov wrote:
I’m new in Ruby. So, my question can seem simple for you. I need to
generate a hex string from some digits: 1, 114, 3, 2 for example. I
need
the following hex representation: 00010072030002 - (0x0001, 0x0072,
0x03, 0x0002).
Not a bad idea, but that won’t exactly do it: he wants only one
octet for the 3.
Oh yes, I didn’t note the 3 was different (I guess it is different
from the rest because of the semantics of the wanted string). With
sprintf that would be