From: Tobias Reif Date: 2001-10-08T21:27:52+09:00 Subject: [ruby-talk:22226] Re: gzip a string Ned Konz wrote: >>how to gzip a string? >> > Just to compress it, or to make a gzip file (which has a header, of course, > that the compressed string itself wouldn't)? What I meant: how to serve a gzipped string? The client expects a gzipped file, so perhaps I need to include the header, thus use the class and methods for writing files? > To compress a string (but not to make it a gzip file): > > #!/usr/local/bin/ruby > require 'zlib' > > defl = Deflate.new > $stdout.print defl.deflate("abcdef\n"); > $stdout.print defl.deflate(nil); How can I make the following work? I try to gzip a string, then unzip it: --- require 'zlib' # using http://www.blue.sky.or.jp/atelier/ruby/ruby-zlib-0.4.0.tar.gz # and ruby 1.6.3 (2001-03-19) [i386-cygwin] initial_string = "Tobi\n" defl = Deflate.new infl = Inflate.new deflated = defl.deflate(initial_string) print deflated # prints xo restored_string = infl.inflate(deflated) print restored_string # prints [nothing] --- Thanks, Tobi -- Tobias Reif http://www.pinkjuice.com/myDigitalProfile.xhtml go_to('www.ruby-lang.org').get(ruby).play.create.have_fun http://www.pinkjuice.com/ruby/