Carl Youngblood wrote: > Hi, I'm trying to embed a binary file inside a ruby script but I'm > having trouble. To test it out, I wrote a simple script that will take > a binary file and encode it to base64 and then decode it again and write > out the result. Here it is: > > require 'base64' > bindata = File.open('oldbinfile').read > File.open('newbinfile', 'w') do |f| > f.write decode64(encode64(bindata)) > end > > When I run this, newbinfile is not identical to oldbinfile anymore. > Anyone know what I'm doing wrong? I'm assuming that the File IO > functions are not binary safe, but what should I use instead? Are you on Windows? If so, 'wb' as a mode might help (binary mode). Hal