www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11087] New: std.file.File.write implicitly converts Unix newlines to Windows newlines

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11087

           Summary: std.file.File.write implicitly converts Unix newlines
                    to Windows newlines
           Product: D
           Version: D2
          Platform: All
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-09-21
11:16:20 PDT ---
-----
import std.file;
import std.stdio;

void main()
{
    std.file.write("test1.txt", "a\nb");

    auto file2 = File("test2.txt", "w");
    file2.write("a\nb");
    file2.close();

    auto res1 = cast(byte[])std.file.read("test1.txt");
    auto res2 = cast(byte[])std.file.read("test2.txt");

    writeln(res1);  // writes [97, 10, 98]
    writeln(res2);  // writes [97, 13, 10, 98]
}
-----

The first file has a \n, but the second file has a \r\n. There is no
documentation saying that File's write method does this internally.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 21 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11087


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|std.file.File.write         |std.stdio.File.write
                   |implicitly converts Unix    |implicitly converts Unix
                   |newlines to Windows         |newlines to Windows
                   |newlines                    |newlines


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-09-21
11:16:41 PDT ---
Fixed title.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 21 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11087



--- Comment #2 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-09-21
11:16:59 PDT ---
Bug found by Orvid.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 21 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11087


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


--- Comment #3 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-09-21
11:20:05 PDT ---
*** This issue has been marked as a duplicate of issue 9776 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 21 2013