Bug 11087 – std.stdio.File.write implicitly converts Unix newlines to Windows newlines

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2013-09-21T11:16:00Z
Last change time
2013-09-21T11:20:05Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2013-09-21T11:16:20Z
----- 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.
Comment #1 by andrej.mitrovich — 2013-09-21T11:16:41Z
Fixed title.
Comment #2 by andrej.mitrovich — 2013-09-21T11:16:59Z
Bug found by Orvid.
Comment #3 by andrej.mitrovich — 2013-09-21T11:20:05Z
*** This issue has been marked as a duplicate of issue 9776 ***