Doubled newlines
Steven Schveighoffer
schveiguy at yahoo.com
Mon Aug 2 05:06:31 PDT 2010
On Sat, 31 Jul 2010 23:10:05 -0400, Andrej Mitrovic
<andrej.mitrovich at gmail.com> wrote:
> Oh and I'm getting the same issue in Python when using CR only. I don't
> know why I have the CR option in the text editor if it doesn't work
> properly. I guess CR is used on the Macs maybe..?
>
> Andrej Mitrovic Wrote:
>
>> I'm getting normal newlines here (XP):
>>
>> C:\output>test.exe
>> import std.file: readText;
>> import std.stdio: write;
>> void main() {
>> string s = readText("test.d");
>> write(s);
>> }
>>
>> The text used CR+LF newlines. I also tried them using LF newlines,
>> which worked fine. But I've then tried with CR and that gives out weird
>> output like so:
>>
>> } write(s);= readText("test.d");
CR means carriage return. This is for old-style line printers. When you
sent a CR, it means, literally, move the carriage back to the front of the
line. When you sent a LF (line feed), it means, feed the paper another
line.
If you printed a file to such a printer with just line feeds, you would
see:
import std.file: readText;
import std.stdio: write;
void main() {
...
If you printed the file with just CRs, you would see all the lines
super-imposed over eachother, because the paper is never moved, just the
carriage is returned.
This is the effect you are seeing, each line is super-imposed over the
other. However, on a terminal, you don't see the residual letters from
previously printed lines, they are completely overwritten.
Essentially, if you put in a sleep between printing each line, what you'd
see is this:
import std.file: readText;
.. pause ..
import std.stdio: write;t;
.. pause ..
void main() {dio: write;t;
....
Hope this helps ;)
-Steve
More information about the Digitalmars-d-learn
mailing list