From: James Gray Date: 2008-12-21T04:43:32+09:00 Subject: [ruby-core:20728] Re: Working with binary strings in Ruby 1.9? On Dec 20, 2008, at 12:49 PM, Hadmut Danisch wrote: > The code I am working on is parsing files with binary content (such as > pictures, machine code, etc.). With 1.8, I could easily use > > * File.open{|f| f.read} to read the contents, In 1.9 use: File.binread(�) > * data[10] to pick the byte code at a given position efficiently data.getbyte(10) > * data[10..20] to extract some bytes efficiently data.bytes.to_a[10..20] > * and use index and rindex to find bytes. data.bytes.to_a.index/rindex Hope that helps. James Edward Gray II