Differences between text formats in windows and Linux
Source: Internet
Author: User
Differences between text formats in windows and Linux-general Linux technology-Linux programming and kernel information. For details, see the following section. In Windows, if a text file is input, a '\ n' line break in the program is interpreted as' \ R' and '\ n' (carriage return and line feed ); on the contrary, if a text file is read, two adjacent '\ R' and' \ n' in the file will be merged into a '\ n' output.
In Unix/Linux, '\ n' is' \ n', which remains unchanged.
Therefore, the formats of text files in Windows and Unix/Linux are different because the '\ n' line breaks in the program are different.
In Linux, the line feed is \ n, while in Windows, the line feed is \ r \ n. If the two files are not processed, problems may occur when they are displayed. For example, if a Linux text file is opened in Windows notepad, the line feed format is not messy, if a Windows file is opened with VI in Linux, ^ M characters will appear.
In Windows, if you use C language to read files as text, Windows will automatically convert \ r \ n to \ n without any conversion in binary mode. In Linux, text and binary are not distinguished.
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.