chr(26) => file reading bug

Michal Bozon bozon at natur.cuni.cz
Tue Mar 28 12:42:02 EST 2000


> Michal Bozon <bozon at natur.cuni.cz> wrote:
> > When it is opened a file containing a char chr(26) (i.e. chr(0x1A)), it is
> > read only until this char.
> >
> > How can it be fixed?
> 
> by reading the fine manual:
> http://www.python.org/doc/current/lib/built-in-funcs.html
> 
>     open(filename, mode, bufsize)
> 
>     /.../ mode indicates how the file is to be opened: 'r' for reading,
>     'w' for writing (truncating an existing file), /.../ Append 'b' to the
>     mode to open the file in binary mode, on systems that differentiate
>     between binary and text files (else it is ignored). /.../
> 
>     If mode is omitted, it defaults to 'r'. When opening a binary file, you
>     should append 'b' to the mode value for improved portability. (It's
>     useful even on systems which don't treat binary and text files
>     differently, where it serves as documentation.)
> 
> and yes, windows 98 differentiate between binary files
> and text files (in text files, this means removing chr(13)
> and treating chr(26) as end of file)
> 
> </F>
 ?
> 
> 
> 
> 

Thanks much. It helped.

Michal Bozon




More information about the Python-list mailing list