2007/8/22, Bertram Scharpf <lists / bertram-scharpf.de>: > Hi, > > Am Mittwoch, 22. Aug 2007, 06:35:32 +0900 schrieb doug meyer: > > I'm having some serious issues writing to a binary file. Can anyone > > give me a hand? > > And could I be having this problem because I'm trying to do this on a > > Linux machine? > > I just repeat what I wrote this afternoon > (<http://www.ruby-forum.com/topic/122170#544613>). > > The distinction between "text" and "binary" is the archetype > misdesign in DOS and Windows. It means nothing more than > that in "text" mode line ends are translated from "\n" to > "\r\n" what is of no use but to disturb file positions and > string lengths. The only purpose of this is to detain > programmers from doing anything in a non-Microsoft way. > Anywhere else you don't need to care. > > Sorry for the flame but that's the way it is. I prefer to just take it as given that different operating systems treat line endings differently and go from there. I can't remember that this caused an issue for me: I open binary files with "rb" and text files with "r" on all platforms. I even find this helps understanding the code better (documentation). And I cannot remember a single case where someone processed a text file and needed exact file positions; line numbers are typically more interesting. Relax :-) robert