open() in binary vs. text mode

Jon Nicoll jkn at nicorp.f9.co.uk
Fri Mar 21 18:47:40 EST 2003


Hi Bob

[...]
> This problem does not appear to have anything to do with the \r\n vs.
> \r vs \n problem.
> 
> When in windows, reading in text mode, if it came across ASCII
> character 26, it would quit and not read any more of the file.  This
> does not happen on other platforms or on windows when reading in
> binary mode.
> 
> Why would a specific character cause this behavior?

Because 26 is 0x1A, or Control-Z, and in ye olde days of DOS 2.x, this
byte value was used as a marker value for 'End of file'. You still
occasionally see this as some form of option on Text editors wishing
to preserve backwards compatability.

    Jon N




More information about the Python-list mailing list