For users without C knowledge there is some magic if std.stdio.File was opened with "w". I just learned the C runtime translates \n to \r\n in the background.
I was using std.ascii.newline because I tried to write OS independent code, but I wondered why the file endings where somehow broken. Please see
https://forum.dlang.org/post/[email protected]
The API reference https://dlang.org/phobos/std_stdio.html#.File
lacks information about this behavior. There is only a link to a C documentiation (http://cplusplus.com/reference/clibrary/cstdio/fopen.html) which also do not explain this behavior.
The only hint is: Use std.ascii.newline for portability (unless the file was opened in text mode)
The API documentation should be enhanced to avoid other D users will fell into this trap.
Comment #1 by robert.schadek — 2024-12-01T16:28:01Z