The documentation for codecs.open()
mentions that
Files are always opened in binary mode, even if no binary mode was specified. This is done to avoid data loss due to encodings using 8-bit values.
How can using text mode for a file lead to "data loss"? It sounds like opening a file in text mode might truncate bytes to 7 bits, but I can't find any mention of this in the documentation: the text mode is described only as a way of converting newlines, with no mention of some potential data loss. So, what does the documentation for codecs.open()
refer to?
PS: While it is understandable that an automatic newline conversion to the platform-dependent newline encoding requires some care, the question is about what is specific about 8-bit encodings. I would have guessed that only some encodings are compatible with the automatic newline conversion, irrespective of whether they are 8- or 7-bit encodings. So, why are 8-bit encodings singled out, in codecs.open()
's documentation?