Home > Operation and Maintenance > Linux Operation and Maintenance > Detailed explanation of linux newline character

Detailed explanation of linux newline character

藏色散人
Release: 2020-02-13 10:12:40
Original
20253 people have browsed it

Detailed explanation of linux newline character

Carriage return and line feed character under Linux system

Recommended: "Linux Tutorial

Brief description

The carriage return and line feed characters are often used in reading and writing text files. It is a little more complicated under Windows, but Linux The system is simpler.

Details

Carriage return and line feed are two different concepts.

Press Enter tells the computer to position the head at the left border; line feed means to move the head down one line.

In Windows: the carriage return character is '\r', going back to the beginning of the line; the line feed character is '\n', changing to the next line at the current position;

In Unix system: I think It is not necessary to add two characters at the end of each line, so there is only a newline character at the end, that is, '\n';

In Mac system: there is only a carriage return character at the end of each line, that is, '\r'.

In other words, when Linux encounters the line feed character '\n', it will perform a carriage return and line feed operation. The carriage return character will only be displayed as the control character '^M' and no carriage return operation will occur; Windows The carriage return and line feed characters must be combined with the carriage return and line feed characters. If they are missing or in the wrong order, the line feed will not work correctly.

It should be noted that in the qt program, just write "\n". It can realize the carriage return and line feed function in Linux or Windows. When opened in a text file, Linux will only have 0x0a, windows will automatically change to 0x0d 0x0a.

Summarize

Detailed explanation of linux newline character

The above is the detailed content of Detailed explanation of linux newline character. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template