From: Todd Benson Date: 2008-03-09T11:22:11+09:00 Subject: Re: bin2str conversion On Sat, Mar 8, 2008 at 7:11 PM, Zangief Ief wrote: > Hello, > > I would like to write a function which is able to convert a binary data > into its string format... > For example, here I have the opposite of my goal: > > str.unpack('c*').collect { |x| sprintf('%02x', x) }.to_s.hex.to_s(2) Just so you know, at least on 1.8.6, this code will only return the binary for one character, the first one. Have you looked at Array#pack? That might be what you look for. Todd