From: Austin Ziegler Date: 2007-02-20T03:37:03+09:00 Subject: Re: byte array to string On 2/19/07, Jim Bob wrote: > I'm sure the must be code for this already without me having to go > through the array byte by byte. > > I have an array of bytes, I need to print this as a string? > > Note the array does not contain text. Your question is ... confusing. You have: a = [ 65, 32, 66 ] When you print it, what do you want to see? "65, 32, 66" # use puts a.join(", ") "A B" # use puts a.map { |e| e.chr }.join "65 32 66" # use puts a.join(" ") "0x41, 0x20, 0x42" # use puts a.map { |e| "0x%02x" % e }.join So, what are you looking for? -austin -- Austin Ziegler * halostatue@gmail.com * http://www.halostatue.ca/ * austin@halostatue.ca * http://www.halostatue.ca/feed/ * austin@zieglers.ca