From: Rafael Date: 2008-07-02T05:32:09+09:00 Subject: Problem with unpack Hi, I'm trying to read a binary file and would want to find within the file a particular substring. I have done the following file = File.open("testFile","rb") str = String.new file.read(512, str) puts (str.length).to_s # how many bytes have I read? strhex = str.unpack("H*") puts strhex # just show me the string to check if (strhex.include?("020")) == true then puts "The tag was found" else puts "The tag was not found" end The tag is not found although I can see (and I know) that the substring 020 is in there. I have tried to find the problem and I realized that the length of strhex is one strhex.length # -> 1 This is certainly the problem. But why is the length only one? Can anyone help? I am also aware that this code is probably not the best way of solving my problem. I'm still learning Thanks Cheers Rafael