C + + about line break

Source: Internet
Author: User
Tags ftp client

Http://blog.chinaunix.net/uid-12706763-id-10830.html

Different OS have different newline characters:
OS Line break Kanji Code
Unix LF JIS, EUC, (ShiftJIS)
Windows Cr+lf ShiftJIS
Macintosh CR ShiftJIS
The transformation relationships between the various systems are listed below:

UNIX = Windows
% Perl-pe ' s/\n/\r\n/' unixfile > Winfile

UNIX = Macintosh
% Perl-pe ' s/\n/\r/' unixfile > macfile
Win = Unix
% Perl-pe ' s/\r\n/\n/' winfile > Unixfile
Windows =& Gt Macintosh
% Perl-pe ' s/\r\n/\r/' winfile > macfile
Macintosh = > Unix
% Perl-pe ' s/\r/\n/g ' macfile > Unixfile
Macintosh = Windows
% Perl-pe ' s/\r/\r\n/g ' macfile > Winfile

In text processing, CR, LF, cr/lf are line breaks used on different operating systems.
DOS and Windows use carriage return + newline cr/lf to represent the next line,
Unix/linux uses the newline character LF to indicate the next line,
The Mac OS system uses a carriage return CR to represent the next line.
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.
The runtime on the general operating system automatically determines the line-wrapping format of the text file. A program that runs on Windows generates a text file in a cr/lf format, while running on Linux generates a text file that is wrapped in the LF format.
A file file that uses another line break on one platform can cause unexpected problems, especially when editing program code. Sometimes the code appears normal in the editor, but when you edit it, the error occurs because of a line break.
Many text/code editors have a newline character conversion feature that allows you to swap line breaks in text files in different formats.
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.

C + + about line break

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.