[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Converting hex or dec to ascii ?

mrpink

4/13/2007 3:48:00 PM

Hi,
I have a variable like:

test = 0x65 0x78

and I wanna have this converted or outputet to-----> ex

which is the ascii code of 0x65 (=e) and 0x78 (=x) . But how can I do
this ?

test = 0x65 doesn't, test = "0x65" doesn't test = String(0x65) also
doesn't...

can someone please help me with this?

greets
3 Answers

Abhijit Gadgil

4/13/2007 4:01:00 PM

0

On 4/13/07, mrpink <adnarim@mail.ru> wrote:> Hi,> I have a variable like:>> test = 0x65 0x78>> and I wanna have this converted or outputet to-----> ex>> which is the ascii code of 0x65 (=e) and 0x78 (=x) . But how can I do> this ?>> test = 0x65 doesn't, test = "0x65" doesn't test = String(0x65) also> doesn't...If you have this in an array, you can use Array#packeg.a = [0x65, 0x78].a.pack("U*")This will work for multibyte unicode strings as well.Hth.-- ??????[written in http://www.pa.../...][http://www.pa...]

Robert Klemme

4/13/2007 4:03:00 PM

0

On 13.04.2007 17:47, mrpink wrote:
> Hi,
> I have a variable like:
>
> test = 0x65 0x78

What exactly is this supposed to mean? This is not valid Ruby:

$ ruby -ce 'test = 0x65 0x78'
-e:1: parse error, unexpected tINTEGER, expecting $

> and I wanna have this converted or outputet to-----> ex
>
> which is the ascii code of 0x65 (=e) and 0x78 (=x) . But how can I do
> this ?
>
> test = 0x65 doesn't, test = "0x65" doesn't test = String(0x65) also
> doesn't...
>
> can someone please help me with this?

Very likely, if we know what your input is.

robert

mrpink

4/13/2007 5:37:00 PM

0

yeah this was wrong varibale too... but I got it out:


shellcode = "\x65\x61"

puts(shellcode)


does what I needed :D