2006
09.19

My current project required a simple operation to perform that took me some time to find in ruby. I’ll put a copy here so hopefully it’s of use to someone:

str.scan(/../).each { | tuple | puts tuple.hex.chr }

So this will convert Hexidecimal tuples into ASCII literals, like follows:

str="48656C6C6F"
str.scan(/../).each { | tuple | puts tuple.hex.chr }
H
e
l
l
o
=> ["48", "65", "6C", "6C", "6F"]

As I say, I couldn’t find this anywhere else, so enjoy.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • HackerNews
  • LinkedIn
  • Reddit
  • StumbleUpon
  • Technorati
  • Twitter

1 comment so far

Add Your Comment
  1. Good Work!!