Return to Snippet

Revision: 32531
at September 28, 2010 03:02 by jimbobmcfred


Updated Code
puts "011010000110010101101100011011000110111100100000".scan(/.{1,8}/).collect{|x| x.to_i(2).chr}.to_s.inspect
puts "hello there".split(//).collect{|x| x.unpack("B*")}.to_s.inspect

Revision: 32530
at September 28, 2010 03:02 by jimbobmcfred


Initial Code
puts "011010000110010101101100011011000110111100100000".scan(/.{1,8}/).collect{|x| x.to_i(2).chr}.to_s.inspect

puts "hello there".split(//).collect{|x| x.unpack("B*")}.to_s.inspect

Initial URL


Initial Description
Quick conversion from a string of binary into ascii, and back again.\r\nUse B* for MSB and b* for LSB first.

Initial Title
Ruby binary string conversion

Initial Tags
ruby

Initial Language
Ruby