[Issue 18962] readln() removes all '\r' characters from stdin
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Jun 9 20:25:36 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18962
Steven Schveighoffer <schveiguy at yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |schveiguy at yahoo.com
Resolution|--- |WONTFIX
--- Comment #1 from Steven Schveighoffer <schveiguy at yahoo.com> ---
This is due to libc on windows attempting to fix the line endings for you.
There's not much D can do about it, since it relies on FILE * to do its i/o.
Note that the reason the single readln affects things is likely because
line-endings are altered when the buffer is filled (which is done with one
large read). All future reads can't recover the removed CRs.
If you want the given behavior, set the mode to binary before doing anything:
_setmode(stdin.fileno, _O_BINARY);
The reason it doesn't occur on Linux is because Linux doesn't do anything in
binary mode.
--
More information about the Digitalmars-d-bugs
mailing list