On Tue, Mar 26, 2002 at 05:39:35AM +0900, Ron Jeffries wrote: > Do you agree that the eof? method should be doing the same thing in > binmode and in text mode? If not ... what am I missing? I think this is a C library issue and not a Ruby issue. If you pass a string as the second parameter to File.open, then Ruby passes that string straight to fopen. When you call f.eof?, Ruby does the same thing whether you are in binary or text mode. If your C library interprets "r" and "rb" differently, then I'm not sure there's much Ruby can or should do about that. The C standard is clear that "r" is for text mode and "rb" is for binary mode. When Ruby does search for end of file, it calls feof to find out if the end-of-file indicator is set. If it is not, then it tries to read, to see if the file pointer is at the end of the file (and if not, puts the character it read back). Ruby does this using getc, which returns an int (not a char). getc has a special return value EOF that indicates end-of-file; note that this is not same as the "end-of-file character" and is well-defined by the C standard. Perhaps there is a linker or compiler option you can use when you compile Ruby to get the C library to ignore the end-of-file character. Paul