------art_27244_22277806.1150578989241
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

On 6/17/06, Michael stepanov <stepanov.michael / gmail.com> wrote:
>
> Hi there,
>
> I'm new in Ruby. So, my question can seem simple for you. I need to
> generate a hex string from some digits: 1, 114, 3, 2 for example. I need
> the following hex representation: 00010072030002 - (0x0001, 0x0072,
> 0x03, 0x0002).
> I tried to use pack:
>
> a = [1, 114, 3, 2]
> hexStr = a.pack('iisi')
>
> but it generate following string: 10007200302000
>
> Also, what is the best way to convert this hex string into digits back?
>
> Thanks in advance.
>
> Michael
>
> --
> Posted via http://www.ruby-forum.com/.
>
> [1, 114, 3, 2].map{|n| "%04x" %n}.join

Hope that helps
Robert
-- 
Deux choses sont infinies : l'univers et la bóŐise humaine ; en ce qui
concerne l'univers, je n'en ai pas acquis la certitude absolue.

- Albert Einstein

------art_27244_22277806.1150578989241--