Opening files in binary mode

When should we consider opening files in binary mode ?
The only difference, really, between binary and text mode files is automatic newline conversions.

A "text mode" file converts your platform's newline sequence (CR LF on Windows, LF on Unix, CR on Mac, and I've read that somewhere someone is actually using LF CR) into a single LF ('\n').

A "binary mode" file doesn't do this conversion --so you see the data exactly as it is on disk. This is important when handling non-textual data.

Hope this helps.
Topic archived. No new replies allowed.