"Ball, Donald A Jr (Library)" <donald.ball / nashville.gov> writes:

> I also tried writing a binary encoder which packs
> and unpacks the bit strings generated by my string encoder, but it fails
> to decompress the entire text for long files, e.g. the program source
> code itself. I'm unsure why, perhaps someone more experienced in this
> arena can suggest why.

As someone else has already been successful at this task with your
program, allow me to propose a guess as to what the problem was: you
were working on windows.

If you just open a file with mode "r" on windows, it'll stop at the
first occurrence in the input of character 26 (ctrl-z).  To read
binary files on windows, you need to open with mode "rb". (or use
binmode on the file)

As for the issue that you can't compress binary data, I'll note that I
got around that by having my tree encode numbers from 0 to 255, instead
of characters, and encoded the number -1 to mean EOF.

-- 
s=%q(  Daniel Martin -- martin / snowplow.org
       puts "s=%q(#{s})",s.to_a.last       )
       puts "s=%q(#{s})",s.to_a.last