IƱaki Baz Castillo wrote:
> Hi, I want to convert some characteres to hexadecimal:
>
>   " " (space)  =>  x20
>   "\t" (tab)   => x09
>
> and so.

>> "x%02x" % " "[0]
=> "x20"
>> "x%02x" % "\t"[0]
=> "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 
integer. You want to convert an integer into a a string, so you'd use 
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
-- 
NP: Depeche Mode - It's No Good
Jabber: sepp2k / jabber.org
ICQ: 205544826