Differences in text file line breaks in different operating systems

Source: Internet
Author: User
Tags ftp client
The logical structure of the text file belongs to the streaming file, and the ASCII encoding standard is used to store the characters. The ASCII standard allows text files that contain only ASCII characters to interact freely between UNIX, Macintosh, Microsoft Windows, DOS, and other operating systems, which is hard to do in other formats. However, in these operating systems, line breaks are not the same, and non-ASCII characters are handled in a inconsistent manner. In MS-DOS and windows in Microsoft, CR and LF two characters are used as line breaks. Unix system, the end of each line only "< newline >", that is, "\ n", Windows system, each line at the end of "< carriage return >< line >", that is, "\ r \ n", Mac system, each line at the end of "< Enter >." A direct consequence is that all text becomes a row when the files under the UNIX/MAC system are open in Windows, and Windows files open under Unix/mac, and a ^m symbol may be shown at the end of each line. Files that are saved by Linux can appear on Windows using Notepad to see black dots. When they can be converted to each other. Under Linux, the command Unix2dos converts the Linux file format into a Windows file format, and the command Dos2unix converts the Windows format into a Linux file format. When using FTP software to transfer files between different platforms, in ASCII text mode, some FTP client programs automatically convert to the line format. The number of bytes of file that has been transferred may vary. If you do not want FTP to modify the original file, you can use bin mode (binary mode) to transfer text. A program that runs on Windows generates a text file that cr/lf in a newline format, while running on Linux generates a text file for the LF format for line wrapping.

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.