From: Joey Date: 2006-06-04T21:32:31+09:00 Subject: Re: Writing encoded images to a file ------=_Part_28934_25961162.1149424347774 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline You could try change: file = File.new("/test.gif", "w") to file = File.new("/test.gif", "wb") So that its in binary mode. j`ey http://www.eachmapinject.com c,y=(r,p,s=%w(rock paper scissors))[rand 3];d={s, {p,0,r,1},p,{r,1,s,0},r,{s,1,p,0}};until y=~/(#{r }|#{s}|#{p})/;$><<"#{[r,s]*", "} #{["or",p]*" "}? ";y=gets.chomp;end;$><<"You:#{y}\nComp:#{c}\n";$>\ <<"You #{d[y][c]?(d[y][c]>0?"Win":"Lose"):"Draw"}\n" On 6/4/06, Aaron Worsham wrote: > > > Word 2003 supports an xml output for documents that uses Base64 to > encode the embedded images. Im looking to grab that image out of the > xml and write it to a file. Im able to parse the xml and isolate the > Base64 string but decoding it out to a file hasn't been working for me; > the image doesn't come back looking correct. Stripped down version of > the code assuming 'AaBaCc' represents the really long Base64 encoded GIF > image string: > > > require 'base64' > str = 'AaBbCc' > file = File.new("/test.gif", "w") > file.syswrite(Base64.decode64(str)) > > > Could be the string coming in, but wanted to get an idea if Im headed in > the right direction with the output before I tackle that debug > nightmare. > > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_28934_25961162.1149424347774--