2006
09.19
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.
Good Work!!