in reply to Binary File Manipulation across Byte boundaries

The problem seems a tad underspecified, making it harder to suggest an approach that's likely to be appropriate. How many bits would make up the target pattern? Would the target pattern always be the same number of bits? Suppose you have a 6-bit target pattern, and it matches the input starting at, say, the 27th bit. At exactly what bit offset does the first output nibble begin? (i.e. do you have to "re-align" the nibble/byte boundary relative to the start of the matched pattern, or will it be okay for the output to remain byte-aligned relative to the start of the input stream?)

Details aside, it does seem as though Bit::Vector will be a good thing to use -- it has everything you need, and plenty more that you will probably never need. But when fiddling with bits, one thing you need most is a detailed spec for what your intentions are.

  • Comment on Re: Binary File Manipulation across Byte boundaries

Replies are listed 'Best First'.
Re: Re: Binary File Manipulation across Byte boundaries
by tperdue (Sexton) on May 18, 2004 at 21:05 UTC
    To answer graff's question, yes I would have to "re-align" the nibble/byte boundary relative to the start of the matched pattern. The pattern size will vary. One of the patterns I'm interested in is 16 bits long.