Re: Tutorial
"Stephen R. van den Berg" <[email protected]>
| Newsgroups | gmane.comp.lang.pike.user |
|---|---|
| Message-ID | <[email protected]> |
Chris Angelico wrote: >>> Stdio.stdin->gets(); >> foo >> (1) Result: "foo\r" >> That seems rather useless. It would break the API to fix it, but on >> the other hand gets() is one of those functions you almost only use in >> tutorials. >Would it break the API? I mean, conceptually, it's retrieving a string >terminated by end-of-line. On Windows, "end-of-line" is often "\r\n". C89 specifies that this normally is solved by the distinction between binary and ascii streams/files. Opening with mode 'b' specifies a binary file, without a 'b' is an ascii file (which on Windows means that line endings of \n are transparently converted back and forth to \r\n on writing and reading). See "man 3 fopen". Pike should be able to put stdin into ascii mode to activate this behaviour. -- Stephen.