Carriage return and line break 1. Meaning & Origin
Enter: Carriage return. Carriage, transport, conveying, train carriages, carriages.
NewLine: Line Feed. The Feed, in its original sense, represents an interface used to receive updates from information sources.
The meaning of the line is very clear, but why is called carriage return, enter the meaning of what is.
OK, let's take a look at their origins.
Before the computer appeared, there was a telex typewriter teletype Model33, which could play 10 characters per second. But since it is a printer, print a line is to wrap, and the line will need to use 0.2 seconds, this time can be hit two characters, if the 0.2 seconds of new data transmission will result in data loss.
The mechanism's researchers then thought of a way to add two characters to the end of each line. One is called carriage return and the other is called line break.
The carriage return is to tell the typewriter to position the printhead at the left edge and the other is called line break, and the print head moves down one line.
Now, the meaning of the carriage return is unclear, and when the print head hits the end of a line, it moves back again and then moves down one line. I see.
But the story was not over yet, and the computer was invented later. With the development of the operating system, some people think that adding two characters is too wasteful, memory is not no money. Add one to it. As a result, the following situation arises:
Windows: End of each line is < Enter >< line break >
Unix: End of each line is < line wrapping >
MAC: End of each line is < Enter >
One of the most immediate consequences is that Windows files are opened in other operating systems with a single symbol (usually ^m), while other system files are placed in a row under Windows.
2. Precautions
When parsing text or other format of the file content, often encountered to determine the return line of the place, when it is necessary to judge the carriage return, but also to determine the newline.
Finally, take a look at their escape character and ASCII code,
' \ n ' 10 newline newline
' \ r ' 13 return car return
Carriage return and line feed characters