Text to Binary and Back Conversion in Ruby -
i have string placed array , turned binary using .pack('b*'). how convert binary data string? .unpack('h*') not solution here, returns string of gibberish.
i have tried in rails console , got following. hope you.
a = "hello".unpack("b*") ## output ["0100100001100101011011000110110001101111"] a.pack("b*") ## output "hello" = "hello".unpack("h*") ## output ["48656c6c6f"] a.pack("h*") ## output "hello"
Comments
Post a Comment