[Issue 3846] New: Unexpected BufferedFile output
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Feb 23 17:59:14 PST 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3846
Summary: Unexpected BufferedFile output
Product: D
Version: 2.040
Platform: x86
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2010-02-23 17:59:12 PST ---
This D2 code:
import std.stream: BufferedFile, FileMode;
import std.conv: to;
void main() {
auto fout = new BufferedFile("foo.txt", FileMode.Out);
int x = 10;
fout.write(to!(const(char)[])(x) ~ "\n");
fout.close();
}
Generates this foo.txt file (bytes expressed in hex):
03 00 00 00 31 30 0a
This Python2.6 program:
fout = file("foo.txt", "w")
fout.write(str(10) + "\n")
Generates this foo.txt file:
31 30 0d 0a
So I don't know if the D code gives the right output.
---------------
Secondary problem, this line:
fout.write(to!(const(char)[])(x) ~ "\n");
can't be replaced by this simpler one, that doesn't work:
fout.write(to!string(x) ~ "\n");
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list