Thread overview
[Issue 8730] writeln stops on a nul character, even if passed a D string
Dec 15, 2013
Musashi Tamura
Dec 16, 2013
Musashi Tamura
December 15, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=8730


Musashi Tamura <yuri.musashi.miwa.tamura@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yuri.musashi.miwa.tamura@gm
                   |                            |ail.com


--- Comment #6 from Musashi Tamura <yuri.musashi.miwa.tamura@gmail.com> 2013-12-15 03:53:31 PST ---
write("test\0gone\n");
write("test\0gone", '\n');
writeln("test\0gon", "e");

All of the above code outputs NUL.
I expect writeln("test\0gone") has the same behavior.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 15, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=8730


monarchdodra@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra@gmail.com


--- Comment #7 from monarchdodra@gmail.com 2013-12-15 10:25:36 PST ---
Has anybody done anything to fix this? If not, then IMO, it's simply invalid.

I think this is "just" an OS output issue: When printing a null character to console, the console seizes to print for the current line.

For example, on windows,
writeln("test\0gone");
prints
test

Yet
writeln("test\0gone\n");
prints
test gone


and
writeln("test\0gon", 'e');
prints
test gone

Weird, right?

So I decided to simply print to file, and check what is actually being *passed* to the stream (NOT what the console prints). Sure enough, everything is correctly placed in the stream, null and all.

Conclusion => Output stream is the one to blame; D passes everything correctly to the stream.

Gonna see how this behaves on linux next.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 16, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=8730



--- Comment #8 from Musashi Tamura <yuri.musashi.miwa.tamura@gmail.com> 2013-12-16 03:13:29 PST ---
This problem is only in "std.stdio.writeln". "std.stdio.File.writeln" doesn't have it.

// abc.d
import std.stdio;
void main() {
    writeln("test\0gone"); // output "test\n"
    stdout.writeln("test\0gone"); // output "test\0gone\n"
}

$ rdmd abc | od -a
0000000   t   e   s   t  nl   t   e   s   t nul   g   o   n   e  nl
0000017

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