Difference between \ n and \ r

Source: Internet
Author: User

Difference between \ n and \ r

Symbol ASCII code meaning
\ N 10 line feed NL
\ R 13 press ENTER CR
 


Press enter \ r. The original meaning is that the cursor returns to the beginning of the line. r returns the English return. The control character can be written as CR, that is, Carriage Return.
Line Feed \ n refers to the next Line of the cursor (not necessarily to the beginning of the next Line). n is an English newline. The control character can be written as LF, that is, Line Feed.
In differentOperating SystemThese two characters are different. For example, in the WIN system, these two characters are the meanings of the representation. In UNIX systems, line feed \ n is represented by the cursor next line and return to the beginning of the line, on MAC, \ r returns to the beginning of the line and goes down one line. The definition of the ENTER key is related to the operating system. Generally, two keys are used together.

 

History:

The origins and differences between Carriage Return and Line Feed.
Before the computer appeared, there was a kind of device called Teletype Model 33, which also came from the tty concept in Linux/Unix. It can contain 10 characters per second. But there is a problem, that is, it takes 0.2 seconds to finish a line break. It can be two characters long. If a new character is passed in the 0.2 s, the character will be lost.
As a result, the developers thought of a way to solve this problem, that is, adding two end characters after each line. One is "return", which tells the typewriter to position the print head on the left boundary; the other is "newline", which tells the typewriter to move the paper down one line. This is the source of "line feed" and "Carriage Return". They can also be seen in their English names.

 

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.