From: 7stud -- Date: 2009-02-09T07:12:52+09:00 Subject: Re: How to capture standart output to variable? Maxim Zhukov wrote: > How to capture output of this code to variable to send it to iconv? > (Just like ob_start() in PHP) > > # ??? > p ["utf-8 string",[123,321],"another string"] > # ??? > puts Iconv.conv("866","UTF-8",captured_output) # because of windows > console You can send output to a string: require "stringio" strio = StringIO.new strio.write("hello world") strio.rewind() puts strio.read() old_out = $stdout $stdout = strio puts " goodbye" $stdout = old_out strio.rewind() puts strio.read() --output:-- hello world hello world goodbye -- Posted via http://www.ruby-forum.com/.