Bug 3347 – std.stdio.writeln attempts to print illegal unicode characters

Status
RESOLVED
Resolution
WONTFIX
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2009-09-26T14:55:00Z
Last change time
2015-06-09T01:28:30Z
Assigned to
andrei
Creator
bugzilla

Comments

Comment #0 by bugzilla — 2009-09-26T14:55:59Z
The following program: import std.stdio; import std.c.stdio; void main() { dchar d; printf("%x\n", d); writeln(d); } correctly shows that d is initialized to \uFFFF, an illegal Unicode character, but writeln attempts to print it anyway as a character.
Comment #1 by andrei — 2009-09-26T17:05:52Z
Should writeln throw here?
Comment #2 by smjg — 2009-09-26T18:28:52Z
What are the rules about valid uses of the permanently unassigned codepoints U+FFFE and U+FFFF? ISTM while it doesn't make sense to write either to stdout, it would be valid to send one, for example, to a MemoryStream for the app's internal use.
Comment #3 by bugzilla — 2009-09-27T20:21:35Z
I don't know what the right answer is, but it has come up and I think it deserves to be an issue. I propose we let it cook for a while and see if anyone comes up with a compelling argument for what the correct behavior should be.
Comment #4 by bugzilla — 2009-10-05T15:05:51Z
Yeah, I think it would probably be a mistake for writeln to throw.
Comment #5 by andrei — 2011-01-16T14:09:10Z
I'm closing this now. Upon further experience, it seems fair to check for Unicode validity in upper layers and leave writeln to write invalid characters on a best-effort basis. If there are solid arguments to the contrary and good alternative ideas, please reopen.