About the line break, win and Mac implementations

Source: Internet
Author: User

' \ R ' is a carriage return, the former makes the cursor to the beginning of the line (carriage return)
' \ n ' is a newline, which moves the cursor down one grid, (line feed)

\ r is the carriage return, return
\ n It's a newline, newline.

for line break this action:
under Unix, there is generally only one 0x0a that represents a newline ("\ n"),
windows is generally 0x0d and 0x0a two characters ("\ r \ n"),
Mac OS system uses a carriage return CR to indicate the next line (\ r)

Unix system, the end of each line only "< line >", that is "\ n";
Inside the Windows system, each line ends with "< enter >< wrap >", or "\ r \ n";
Mac system, the end of each line is "< Enter >", that is, "\ r".
A direct consequence of this is that if the file under the Unix/mac system is opened in Windows, all the text will be turned into one line, and if the file in Windows is opened under Unix, it will be more than a ^m character at the end of each line.
DOS and Windows with carriage return + newline CR/LF represents the next line, that is, ^m$ ($ is not a newline character, newline characters are not represented, $ is the representation of the end of text EOF)
Unix/linux uses the newline character LF to indicate the next line, \ n
The Mac OS system uses a carriage return CR to represent the next line, which is \ r

The CR symbol ' \ r ' indicates that the decimal ASCII code is 13 and the hexadecimal code is 0x0d;
LF using the ' \ n ' notation, the ASCII code is 10, and the 16 system is 0x0a. So the line breaks in the Windows platform are represented in a text file using 0d 0a two bytes, while the line breaks on UNIX and Apple platforms are expressed in 0a or 0d of a byte.

Because of the DOS style of the line to use \ r \ n, to upload such a file to UNIX, some versions of VI does not recognize \ r, so vi display at the end of the ^m will appear, but some can identify \ r \ n, normal display carriage return line.

About the line break, win and Mac implementations

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.