Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
772 views
in Technique[技术] by (71.8m points)

text - Order of carriage return and new line feed

Is it important to have the correct order of carriage return then new line feed? For text editors does it matter in what order they appear?

For example instead of



this




Seems like Jeff has allready writen up a very nice Blog Post on the subject.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The traditional order, when both control characters are used, is Carriage Return, then Line Feed.

The reason for this goes back to the old ASR-33 Teletype.

When a Carriage Return is issued to an ASR-33, the print head, if it is near the right margin, takes over a tenth of a second to return to the left margin, plus there is a bit of "bounce" when the left margin is hit.

If the order were Line Feed, then Carriage Return, the first printed character might occur a tenth of a second after the Carriage Return, and thus might end up printing (as a smear) halfway across the page. But if Line Feed comes after Carriage Return then the time taken by the Line Feed provides extra time for the print head to complete it's trip.

Some systems (I'm thinking the old Xerox Sigma 7 OS, eg) do Line Feed then Carriage Return, but they inject, eg, NULL characters into the data stream to allow the print head to do it's thing.

And, of course, when you get to faster devices (some early 30 CPS teleprinters, eg), the problem gets worse and a more complex strategy is required.

(There is also the point that, for user input, the Carriage Return is provided by the user pressing the Return key, while the Line Feed must be provided by the computer. For this reason it was often the "style" to have normal print lines begin with Line Feed and end with Carriage Return. A prompt for user input, then, consisted only of a Line Feed, while the user input ended with the Carriage Return. This scheme worked well when used consistently, but of course that didn't always happen.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...