Rookie essay (1)---line break for different operating systems for Windows, Unix, and Mac carriage return \ r and newline characters \ n

Source: Internet
Author: User
Tags ftp client

A rookie turned out, the yard of the world to break into a daily progress more than lost.

                 

   Windows, Unix, Mac line breaks for different operating systems carriage return \ r and newline characters \ n

First, the concept:

Line feed ' \ n ' and carriage return ' \ R '

(1) NewLine character is another line---' \ n ' 10 newline (newline)

(2) The carriage return is back to the beginning of the line---' \ r ' 13 return car (return)

So we usually write the file carriage return should be exactly called carriage return line break

CR: Enter (carriage return) \rlf: newline (line Feed) \ n

Second, the application:

(1) in MS-DOS and windows in Microsoft, use "Enter CR (' \ R ')" and "line feed lf (' \ n ')" Two characters as line feed;

(2) Inside the Windows system, the end of each line is carriage return + newline (CR+LF), that is, "\ r \ n";

(3) Unix system, the end of each line is only a newline LF, that is, "\ n";

(4) in Mac system, the end of each line is the carriage return CR is ' \ r '.

The line break for Mac OS 9 and the previous system is CR, and the newline character starting with Mac OS X (later renamed OS X) is LF, ' \ n ', and Unix/linux is unified.

Third, Impact:

(1) A direct consequence is that the files in the UNIX/MAC system open in Windows, all the text will become a line;

(2) While the files in Windows are opened under Unix/mac, a ^m symbol may be found at the end of each line.

(3) A black dot appears on a Linux saved file that is viewed in Notepad on Windows.

Four, can be converted to each other:

Under Linux, the command Unix2dos converts the Linux file format to the Windows file format, and the command Dos2unix converts the Windows format to the Linux file format.

When transferring files between different platforms using FTP software, in ASCII text mode transfer mode, some FTP client programs automatically convert to the line format. The number of file bytes passed through this transfer may vary.

If you do not want FTP to modify the original file, you can use bin mode (binary mode) to transfer the text.

A program runs on Windows to generate a text file in CR/LF format, while running on Linux generates a text file with the LF format wrapped.

Rookie essay (1)---line break for different operating systems for Windows, Unix, and Mac carriage return \ r and newline characters \ n

Related Article

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.