M
Matthew Moss
In irb 0.9 (ruby 1.8.2) in cygwin/WindowsXP:
I would have though that at least one of "I" or "V" in the unpack call
would have given me the correct answer, 6. I'm reading this data out
of a binary file, stored in big-endian, but neither handles this.
I managed to get the right answer by doing:
x.unpack("C*").reverse.pack("C*").unpack("I")
But that seems rather silly. So I guess I'm asking:
1. Is unpack broken, or is there a big-endian option I missed?
2. Is there a more generic module/library for reading binary files?
3. Is there an existing modules/lib for reading MIDI files?
thanks...
=3D> [100663296]a =3D [0, 0, 0, 6] =3D> [0, 0, 0, 6]
x =3D a.pack("C*") =3D> "\000\000\000\006"
x.unpack("I") =3D> [100663296]
x.unpack("V")
I would have though that at least one of "I" or "V" in the unpack call
would have given me the correct answer, 6. I'm reading this data out
of a binary file, stored in big-endian, but neither handles this.
I managed to get the right answer by doing:
x.unpack("C*").reverse.pack("C*").unpack("I")
But that seems rather silly. So I guess I'm asking:
1. Is unpack broken, or is there a big-endian option I missed?
2. Is there a more generic module/library for reading binary files?
3. Is there an existing modules/lib for reading MIDI files?
thanks...