From: Jed Hurt Date: 2007-09-10T11:22:35+09:00 Subject: Re: Possible Zlib Bug It was a bonehead error. String#slice!(0..8) consumes the first 9 bytes of the string. String#slice!(0..7) fixed it. Sorry for the noise. On 9/7/07, Jed Hurt wrote: > I posted to core as I assumed that this would be the mailing list with > the most knowledge of Ruby's Zlib library. Please forgive me if I > should have posted to the general list. > ==================================================== > > I'm porting SWX PHP ( swxformat.org ) to Ruby. The idea is to assemble > Flash SWF files by converting data to SWF bytecode. SWF files support > compression using ZLib, and so I'm implementing compression using > Ruby's ZLib library. > > As I'm porting SWX PHP to Ruby, I am able to generate a SWF file using > SWX PHP to see what I need to generate in rSWX ( my port ). > > There seems to be a bug in Ruby's ZLib implementation that creates a > different header and trailer than PHP's gzcompress() (the function > used to compress in SWX PHP). > > Here is the bytecode of two SWF files containing the same data (one > generated with SWX PHP and the other generated with rSWX): > http://pastie.caboo.se/95038 > > I've highlighted the discrepant parts of the two files (Please note > that the first 8 bits of a compressed SWF file are left uncompressed, > thus the header of the compressed section of the file starts on the > second line of the pastied result). > > And, needless to say, the compressed SWF file generated with SWX PHP > works, and the one generated with rSWX does not. > > I know very little about compression or Zlib so I'm quite lost at this > point. I'm hoping somebody can give me some advice on how to proceed > with debugging this issue. >