On a little bit of a tangent, network-based file transfers typically take "text mode" as an excuse to only transmit seven bits per byte, reducing the total data stream by 12.5%; obviously this ruins anything that doesn't fall strictly within the 128-character ASCII range.
MKlegoman357, on 12 December 2015 - 03:11 PM, said:
There's no "conversion" going on.
Er, yes there is. Even
file.readAll() will strip out carriage returns, and so will
file.write() - this goes regardless as to whether you put them back in again between reading and re-writing!
Lupus590, on 12 December 2015 - 02:48 PM, said:
Linux, Windows and Mac all have a different way of storing a new line. The conversion process converts the other two to the one your OS prefers.
Running CC under Windows (as I imagine most users do), I find it seems locked to "convert to Unix" - line-feeds only, no carriage returns.
blunty666, on 12 December 2015 - 02:14 PM, said:
Is it possible to tell when a file has been written in binary mode vs text mode?
No, because binary mode allows you to write a file exactly how you want it, bit-for-bit; this means that it's always possible a file was written using binary mode.
By inspecting file content via binary mode, it becomes possible to tell whether it's "safe" to use text mode on it... but unless you want to actually use the text in a file for text-based purposes, there's no point; text mode makes it easy to parse that data into
strings, but that's the only benefit to using it. If you just want to copy files around, stick with binary mode all the way.