From: Ammar Ali Date: 2010-12-27T20:58:52+09:00 Subject: Re: how to change it in to hex? On Mon, Dec 27, 2010 at 1:32 PM, Pen Ttt wrote: > ni my console,hexdump -C /home/pt/kc|less,what i get is : > > 00000000  00 00 00 00 56 b8 32 01  06 13 00 00 00 00 00 00 > 00000010  00 00 00 00 00 00 1f ab  ca 48 00 00 00 00 00 00 > > irb(main):011:0> IO.read('/home/pt/kc', 8, 0x00) > => "\000\000\000\000V\2702\001" > > how to make   "\000\000\000\000V\2702\001"  become  00 00 00 00 56 b8 32 > 01? One way is to use String#unpack to get the individual bytes from the data string, (C* for a sequence of unsigned chars), then use Array#map to convert the values to hex, finally to format with spaces between the octets, use Array#join. Regards, Ammar