From: "Peña, Botp" Date: 2008-07-02T19:35:38+09:00 Subject: Re: Problem with unpack From: Rafael [mailto:mayoral.rafael@gmail.com] # strhex = str.unpack("H*") you assume the return value is a string :) botp@botp-desktop:~$ qri string.unpack ---------------------------------------------------------- String#unpack str.unpack(format) => anArray ------------------------------------------------------------------------ Decodes str (which may contain binary data) according to the format string, returning an array of each value extracted. The format string consists of a sequence .... verify it by using #class method eg, p strhex.class # and look for the desired group within this "transformed" string # if (strhex.include?("02001000")) == true then c/c++-ism ;) lose the "== true" portion, if strhex[0].include?("02001000") or much better, strhex = str.unpack("H*")[0] #<---note the index for 1st elem if strhex.include?("02001000") puts "The tag was found" .... or something like that # As I said, this doesn't work (it reports the tag was not found!) and I # wonder whether it has something to do with the fact that # # strhex.length # -> 1 you got a hint there. should have check it further ;) # By the way, if after unpacking I do # puts strhex try, p strhex # then I get the correct string, that is exactly the same as hexdump # shows me on the left-hand side. # So strhex seems to contain what I need, but still there is some kind # of problem. that implies that you are very close to your objective ... hth. kind regards -botp