Sebastian Hungerecker
5/13/2008 1:30:00 PM
I=C3=B1aki Baz Castillo wrote:
> Hi, I want to convert some characteres to hexadecimal:
>
> " " (space) =3D> x20
> "\t" (tab) =3D> x09
>
> and so.
>> "x%02x" % " "[0]
=3D> "x20"
>> "x%02x" % "\t"[0]
=3D> "x09"
> I'm trying using to_i(16) but don't get it working at all.
String#to_i(b) converts a string representing a number in base b to an=20
integer. You want to convert an integer into a a string, so you'd use=20
Integer#to_s(16) except that that would return "9" (instead of "x09"
like you want) for "\t", so I used % (sprintf) above.
> Any help please?
HTH,
Sebastian
=2D-=20
NP: Depeche Mode - It's No Good
Jabber: sepp2k@jabber.org
ICQ: 205544826