From: ara.t.howard@... Date: 2006-09-07T00:11:14+09:00 Subject: Re: constructing a string from hex value On Wed, 6 Sep 2006, Srdjan Marinovic wrote: > hi, > > How do I construct a string out of hex values? > In other words I want to give exact hex value for each byte in the > string. So I would have soemthing like > > 0x2a, 0x7e, 0x0a, 0x7e > > If I go through Fixnum I get my string to contain numbers 48, 115, 10, > 115 but I do not want that but rather a string of ASCII(48), > ACII(115),... > > Thanks > > srdjan the append operator of String does what you want with Fixnums. as others have pointed out you can use pack to initially contruct it. but you can also continue to build it up with a simple '<<' harp:~ > cat a.rb s = [ 0x2a, 0x7e, 0x0a, 0x7e ].inject(''){|s,c| s << c} p s[0] p 0x2a harp:~ > ruby a.rb 42 42 regards. -a -- what science finds to be nonexistent, we must accept as nonexistent; but what science merely does not find is a completely different matter... it is quite clear that there are many, many mysterious things. - h.h. the 14th dalai lama