www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16561] New: API documentation: C runtime behavior of


          Issue ID: 16561
           Summary: API documentation: C runtime behavior of
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: andre s-e-a-p.de

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/smslryopqywdwtzicxnp forum.dlang.org

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.

Sep 28 2016