daniel åkerud
6/10/2008 8:38:00 AM
[Note: parts of this message were removed to make it a legal post.]
Hello, I am converting to and from hex nibbles using the code below. Is
there a smarter way for this?
To hex nibbles:
'testing 123'.scan(/./).collect { |i| i.unpack('C')[0].to_s(16) }.join
=> "74657374696e6720313233"
and back to binary:
"74657374696e6720313233".scan(/../).collect { |i| i.to_i(16) }.pack('C*')
=> "testing 123"
Thanks,
/D