Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > from Hex to string

Reply
Thread Tools

from Hex to string

 
 
Une bévue
Guest
Posts: n/a
 
      03-08-2006
i have datas like that :

646c6532 00000000 61657674 0000012e 00000000 00000000 0000011c 00000004
00000001 00000000 00000000 00000000 [...]
6c6f6e67 00000004 00000000 66726f6d 70736e20 00000008 00000000 005c0001
3b3b3b3b 2d2d2d2d 54455854 00000006 626d6b6d 3a76


seems to be hex encoded US-ASCII (?)

how to convert that in user readable us-ascii ? (to string)

i now i have the sequence "70736e20" which is "psn "
--
une bévue
 
Reply With Quote
 
 
 
 
Mikkel Bruun
Guest
Posts: n/a
 
      03-08-2006
String unpack

http://ruby-doc.org/core/classes/Str...c/M001436.html
On Wednesday, March 08, 2006, at 6:13 PM, wrote:
>i have datas like that :
>
>646c6532 00000000 61657674 0000012e 00000000 00000000 0000011c 00000004
>00000001 00000000 00000000 00000000 [...]
>6c6f6e67 00000004 00000000 66726f6d 70736e20 00000008 00000000 005c0001
>3b3b3b3b 2d2d2d2d 54455854 00000006 626d6b6d 3a76
>
>
>seems to be hex encoded US-ASCII (?)
>
>how to convert that in user readable us-ascii ? (to string)
>
>i now i have the sequence "70736e20" which is "psn "
>--
>une b�vue
>



Mikkel Bruun

www.strongside.dk - Football Portal(DK)
nflfeed.helenius.org - Football News(DK)
ting.minline.dk - Buy Old Stuff!(DK)




--
Posted with http://DevLists.com. Sign up and save your time!


 
Reply With Quote
 
 
 
 
Gregor Kopp
Guest
Posts: n/a
 
      03-08-2006
a = String.new
a << "70".hex
puts a

look at http://www.rubycentral.com/book/builtins.html in String


Une bévue schrieb:
> i have datas like that :
>
> 646c6532 00000000 61657674 0000012e 00000000 00000000 0000011c 00000004
> 00000001 00000000 00000000 00000000 [...]
> 6c6f6e67 00000004 00000000 66726f6d 70736e20 00000008 00000000 005c0001
> 3b3b3b3b 2d2d2d2d 54455854 00000006 626d6b6d 3a76
>
>
> seems to be hex encoded US-ASCII (?)
>
> how to convert that in user readable us-ascii ? (to string)
>
> i now i have the sequence "70736e20" which is "psn "

 
Reply With Quote
 
Une bévue
Guest
Posts: n/a
 
      03-08-2006
Mikkel Bruun <devlists-ruby-> wrote:

> String unpack
>
> http://ruby-doc.org/core/classes/Str...c/M001436.html


thanks !
--
une bévue
 
Reply With Quote
 
Une bévue
Guest
Posts: n/a
 
      03-08-2006
Gregor Kopp <> wrote:

> a = String.new
> a << "70".hex
> puts a
>
> look at http://www.rubycentral.com/book/builtins.html in String


ok, thanks
--
une bévue
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
hex string to hex value tim Python 8 11-23-2005 06:27 PM
[Fwd: Re: hex string to hex value] tim Python 2 11-23-2005 07:18 AM
Hex Color Codes - Hex 6 <=> Hex 3 lucanos@gmail.com HTML 10 08-18-2005 11:21 PM
hex value in string back to real hex value jack Python 4 09-08-2004 07:11 AM
hex(-5) => Futurewarning: ugh, can't we have a better hex than '-'[:n<0]+hex(abs(n)) ?? Bengt Richter Python 6 08-19-2003 07:33 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57