From: Han Holl Date: 2006-05-21T18:46:44+09:00 Subject: How to reverse String.unpack('H*') ------=_Part_1418_6249780.1148204801949 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hello rubyists, I have binary numbers that through an ODBC interface are decoded with String.unpack('H*'). Let's give an example: the number 23. b=3D'xxxx' b[0]=3D23; b[1] =3D b[2] =3D b[3] =3D 0 b.unpack('I') =3D> [23] b.unpack('H*') =3D> ["17000000"] The problem: how do I convert "17000000" to 23 ? The following works, but seems awfully complex: fl =3D "17000000" fl.unpack('a2a2a2a2').collect {|x| "0x#{x}".hex}.pack('I').unpack('I')[0] Any suggestions ? Han Holl ------=_Part_1418_6249780.1148204801949--