Possible Duplicate:
Hex to binary in ruby
In Python, I can do the following:
>>> str = '000E0000000000'
>>> str.decode('hex')
'\x00\x0e\x00\x00\x00\x00\x00'
If I have to achieve the same output in ruby which call could I make? I tried to_s(16)
, which doesn't seem to work. I need the output to be in that specific format, so I expect to get the following:
"\\x00\\x0e\\x00\\x00\\x00\\x00\\x00"