Carriage return and line feed characters

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.