P
Peter Bailey
I am writing a templating system to replace tags and values in template
files. I am quite new to Ruby and am not sure I am going about things
correctly. My prog runs great on text files, rtf, etc., but I am running
into problems outputting to binary formats (e.g. word - sigh). My program
just reads the whole file into a string, works on that, and then I
output to another file using puts. This causes grief for word or open
office etc when it tries to open the newly created file.
I tried a simple test just reading in the file and writing it out, and I
see that the puts adds 1 byte to the eof, a LF (working on OS X). I got
the impression from reading docs that the puts would not mess with my
ouput, but that is obviously not the case, as my simple test has shown.
So, can anyone point me to a better way to write out the binary data so
that it is not altered (except by me on purpose). I looked at the data
input into a string, and it is correct. It is the output that is
breaking things.
Any help/pointers to explanations of how puts really works etc. or
better alternatives much appreciated.
Peter
files. I am quite new to Ruby and am not sure I am going about things
correctly. My prog runs great on text files, rtf, etc., but I am running
into problems outputting to binary formats (e.g. word - sigh). My program
just reads the whole file into a string, works on that, and then I
output to another file using puts. This causes grief for word or open
office etc when it tries to open the newly created file.
I tried a simple test just reading in the file and writing it out, and I
see that the puts adds 1 byte to the eof, a LF (working on OS X). I got
the impression from reading docs that the puts would not mess with my
ouput, but that is obviously not the case, as my simple test has shown.
So, can anyone point me to a better way to write out the binary data so
that it is not altered (except by me on purpose). I looked at the data
input into a string, and it is correct. It is the output that is
breaking things.
Any help/pointers to explanations of how puts really works etc. or
better alternatives much appreciated.
Peter