Carriage return and line feed story

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/m0_37907797/article/details/83661529

When compiled before school, the teacher did not know a fight when you change lines, always line breaks and carriage returns that they had heard of such a story ...

A long time ago, there is something called teletype (Teletype Model 33 ASR) machine, the computer was not yet such a thing. On such a typewriter, there is a call Carriage made member, which is the printhead, a cursor corresponding to the typewriter. Each input character, the cursor forward one space. When the full-line character input cursor back from the far left of the next line to start printing.

This time triggers two actions, a cursor is moved downward in the vertical direction, a horizontal direction is moved to the coordinates of the cursor. Then this typewriter can play 10 characters per second, the equivalent of 0.1 seconds to play a character; and to complete the two actions take time to 0.2 seconds, 0.2 seconds if in this, there are new characters pass over, then these characters will be lost.

To solve this problem of lost character, development staff in the back of each line adds two characters represent the end of a line: one called carriage return (Carriage return) , the equivalent of telling typewriter, move the cursor to the left in the horizontal direction ; called a line feed (line Feed) , equivalent to tell typewriter, move the cursor to the next line in the vertical direction.

This is the carriage return and line feed derived.

Later, the computer appeared, these two concepts also took over. But then stored equipment is very expensive, some people think that with the two characters used to indicate the end of a line is very wasteful, so have a branch, different vendors have different approaches.

In these operating systems, the end of the Unix operating system per line wrap , namely "\ n"; Windows is a carriage return + line , that is, "\ r \ n"; and Mac systems use a carriage return to represent the end of that "\ r".

When this reason, we sometimes will lead to open systems with Windows Unix / Mac file system, there will be all the text case to one line, and open the file in the Windows system with Unix and Mac systems, in each row the end will be more of a ^ M character.

Finish

I am concerned about the number of public congregation: hard to force the yard farming for more original articles, backstage reply packs give you a special resource spree. Also thanks to the public who number more needed to introduce the article.

Guess you like

Origin blog.csdn.net/m0_37907797/article/details/83661529