Reprint Link: http://blog.csdn.net/tskyfree/article/details/8121951
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
Second, the application:
(1) in MS-DOS and windows in Microsoft, use "carriage return CR (' \ R ')" and "newline LF (' \ n ')" two characters as newline character, (2) inside the Windows system, each line ends with a carriage return + line feed (CR+LF), i.e. "\ r \ n" ; (3) in UNIX systems, each line ends with a newline CR, or "\ n", and (4) the Mac system, where each line ends with a carriage return CR that is ' \ R '.
third, Impact:(1) A direct consequence of this is that the files in the UNIX/MAC system open in Windows, all the text will become a line, (2) and the Windows file under Unix/mac Open, at the end of each line may be more than a ^m symbol. (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 is to convert the Linux file format to the Windows file format, and the command Dos2unix to convert 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.
Windows, Unix, Mac line breaks for different operating systems-parse carriage return \ r and newline characters \ n