Thread overview | |||||
---|---|---|---|---|---|
|
August 01, 2010 [Issue 4555] New: Double newlines with std.file.readText | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=4555 Summary: Double newlines with std.file.readText Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody@puremagic.com ReportedBy: bearophile_hugs@eml.cc --- Comment #0 from bearophile_hugs@eml.cc 2010-08-01 14:10:49 PDT --- This is a D2 program: import std.file: readText; import std.stdio: write; void main() { string s = readText("test.d"); write(s); } With DMD 2.047 on a 32 bit Windows Vista Home this D2 program prints all newlines doubled (assuming the program is named "test.d"): import std.file: readText; import std.stdio: write; void main() { string s = readText("test.d"); write(s); } Saving the same source code with in UNIX style the doubling of newlines doesn't happen. One or two testers have not found this problem on Windows XP. This program: import std.file: readText; import std.stdio: write; void main() { string s = readText("bug15.d"); foreach (c; s[0 .. 35]) write(cast(int)c, " "); } Prints: 105 109 112 111 114 116 32 115 116 100 46 102 105 108 101 58 32 114 101 97 100 84 101 120 116 59 13 10 105 109 112 111 114 116 32 Note the normal sequence of the newline of the first line plus the "i" char at the start of the second line: 13 10 105 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 21, 2013 [Issue 4555] Double newlines with std.file.readText | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=4555 Nick Sabalausky <cbkbbejeap@mailinator.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |cbkbbejeap@mailinator.com --- Comment #1 from Nick Sabalausky <cbkbbejeap@mailinator.com> 2013-03-21 08:03:08 PDT --- The 'write' function converts \n to \r\n on windows (And therefore also converts \r\n to \r\r\n). Is it possible this problem is *just* write and not readText at all? Try converting all of the 'write' into 'stdout.rawWrite'. Also, since windows command line displays *both* \n and \r\n as single newlines, your test should redirect the output to a file, and then examine the result in either a hex editor or a code editor that supports displaying line-ending characters (such as Programmer's Notepad 2). I suspect this issue may simply be the same as #9776: http://d.puremagic.com/issues/show_bug.cgi?id=9776 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 24, 2013 [Issue 4555] Double newlines with std.file.readText | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=4555 --- Comment #2 from bearophile_hugs@eml.cc 2013-03-23 18:32:06 PDT --- (In reply to comment #1) > Try converting all of the 'write' into 'stdout.rawWrite'. If I use stdout.rawWrite then the duplication of newlines (in the first program) doesn't happen. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation