What is the difference between carriage return and line feed? Do we press ENTER or line feed? [Posting]

Source: Internet
Author: User

Introduction: Reading symfony
$ Value = str_replace (Array ("/R/N", "/R"), "/N", $ value) is found in the source code );

 

What is the difference between carriage return and line feed?

(Link: http://www.52rd.com/Blog/Detail_RD.Blog_imjacob_12317.html
)

 

/N is a line feed, linefeed in English, and ASCII code is 0xa.
/R is the carriage return, carriage return in English, and ASCII code is 0xd.

If you have used a mechanical typewriter, you will know the difference between carriage return and line feed...
WRAP is to roll the drum to one grid without changing the horizontal position.
Press enter to reset the horizontal position without rolling the drum.

But do we usually press enter to press the carriage return or line feed? Isn't it clear ??
In Windows, enter is/n/R, UNIX is/N, and Mac is/R.

In the MS system, a carriage return key is entered with two characters in plain text format, and a carriage return and a line break are entered. In Linux, it is just a carriage return.
// The above content references the http://topic.csdn.net/t/20040617/23/3101951.html
# And http://topic.csdn.net/t/20021113/09/1171659.html
.

File Operations during programming

WB (binary mode) or wt (text mode) also have an impact. I did an experiment (experiment uses. net2003)
Enter 12 in the 01.txt file and enter. In ultraedit, the binary value is 31 32 0d 0a.

Then the program is as follows:

Int Mian ()
{File * FP1, * fp2, * fp3, * fp4, * FP5, * FP6;
 
Char A [10];
Char B [10];

FP1 = fopen ("01.txt"," R ");
 
Fp3 = fopen ("02.txt"," W ");
Fread (A, sizeof (unsigned char), 8, FP1); // 31 32 0a in

Fwrite (A, sizeof (unsigned char), 8, fp3); // 31 32 0d 0a in 02.txt
In the case of input, the newline carriage return is converted into a newline, and then the newline will be converted into a newline carriage return.



Fclose (FP1 );
Fclose (fp3 );

Fp2 = fopen ("01.txt"," rb ");

Fp4 = fopen ("03.txt"," WB ");

Fread (B, sizeof (unsigned char), 8, fp2); // 31 32 0d 0a in B

Fwrite (B, sizeof (unsigned char), 8, fp4); // 31 32 0d 0a in 03.txt, because
In binary cases, carriage return and line feed (similar to text conversion) do not exist.

Fclose (fp2 );
Fclose (fp4 );

Return 0;
}
The conclusion is as follows: In the Read mode, in the text mode, enter is 0x0a; in the binary mode, enter is 0x0d, 0x0a.

Also, in text mode, carriage return-linefeed
Combinations are translated into single linefeeds on input, and
Linefeed characters are translated to carriage return-linefeed
Combinations on Output
Unicode stream-I/O function operates in text mode (the default),
Source or destination stream is assumed to be a sequence of multibyte
Characters. Therefore, the Unicode stream-Input Functions convert
Multibyte characters to wide characters. For the same reason,
Unicode stream-output functions convert wide characters to multibyte
Characters.

Open in binary (untranslated) mode; translations involving
Carriage-return and linefeed characters are suppressed.
(In binary cases, the conversion between carriage return and line feed does not exist ).

Again reference an article: http://zhidao.baidu.com/question/27868102.html? Fr = qrl3

Soft and hard press ENTER}

A hard carriage return is generated by pressing a carriage return. It also acts as a line break and separates paragraphs.
The soft carriage return is generated by SHIFT + enter. It breaks the line but does not change the segment. That is, the two paragraphs before and after the soft carriage return belong to the same "segment" in word ". You will understand this in the application format.

Switch:

Edit -- replace, click "advanced", click "search content", enter "manual linefeed" in "special characters", and then click "Replace with" to add the section mark in "special characters, click "replace all.

There is only one type of Enter key on the keyboard, but there are two different types of line breaks. It is a miracle.

Me
Press enter, which is the curved Small Arrow generated by hitting Enter in word, occupies two bytes. This type of carriage return can effectively mark the paragraph out clearly. Press enter on two hard drives.
The text in the paragraph is a paragraph. You can set a paragraph mark for it without worrying about the impact of other paragraphs. This is why we are used to using hard carriage return: convenient typographical layout.

But press Enter.
It also brings us trouble. If you are a web designer or a forum Ranger, you must have the following experience: when you plan to change the line, the line you want to change is not flattering, and the line spacing is too large! In fact, this is the same as press Enter.
The principle is the same, but it is not displayed in the text editor such as Word ". However, this typographical style does cause a lot of difficulties. At this time, we have to ask the brothers who press Enter: Soft back.
Car.

Soft press ENTER occupies only one byte, and is a downward arrow in word. If you have copied text from a complex web page to a word, you will not be unfamiliar with it. However
It is not that easy to enter a soft press enter directly in word. Because soft carriage return is not a paragraph mark, it just starts a new line, not a segmentation. Therefore, it is not very conducive to text layout, because it cannot
Assign a special format to a separate segment. However, it still plays an important role in web design.

Soft press ENTER can greatly reduce the line spacing between the two rows, because
It is not a paragraph mark, it must be different from the legal paragraph mark-hard carriage return. The HTML code of the hard carriage return is <p>... </P>, and the content of the paragraph is in it,
The soft carriage return code is very lean: <br>. Therefore, if you want to use soft carriage return on a webpage, you only need to switch to the code page and type the soft carriage return code.
Next, let's talk about the conversion of carriage return when different editors copy texts to each other.

As everyone on Earth knows, if the text on the webpage is copied to word, press enter to change to a curved arrow, and press enter to the downward arrow. As a result, the friends who are used to editing text with word are not very comfortable.

The same is true for copying text in word to a webpage. It can be said that word is compatible with Web pages, or how can we choose "Save As web page?

Note
This is also a relatively large editor. But in recent years, with the development of society and the disadvantages of notepad, many people have entered the Cold palace. I can only express my regret for this, because the functions of notepad are not rich.
Is the advantage that other editors cannot replace. When you copy the text on the webpage again, paste it in notepad. Haha, no matter what the webpage designer uses, it is now a carriage return! How
Don't you believe it? Let's take a look: soft carriage return is a normal carriage return, and hard carriage return is a normal carriage return. You can copy text from notepad to word, and press enter in notepad is hard.
Enter! Copy the text from the notepad to the Web Editor. All the carriage returns are soft carriage returns !!

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.