This is the 24th day of my participation in the August Text Challenge.More challenges in August

In daily development and work, we often use the Enter key on the keyboard. Many people think that the Enter key is the newline, which is actually the illusion given by the key on the keyboard. In fact, in the original computer, the Enter key and the newline are two different concepts.

More articles in my Github and personal public account [full zhandao road], welcome to watch [an unknown football dog’s front knowledge point], if there are benefits, do not pay, little hands point a Star.

Read this article and you will learn

  • The origin of line feeds and carriage returns
  • The difference between line feed and carriage return

The origin of line feeds and carriage returns

  • Before computers, there was a teletype machine that could type 10 characters per second. One problem is that it takes 0.2 seconds to type a newline, which is exactly two characters. If a new character is passed within 0.2 seconds, the character will be lost.

  • So the developers figured out a way to solve this problem by adding two ending characters to each line. One, called carriage return, tells the typewriter to position the print head on the left edge. The other, called line break, tells the typewriter to move the paper down one line.

  • Later, computers were invented, and these two concepts were applied to computers. Back then, memory was expensive, and some scientists thought it was wasteful to add two characters to the end of each line; just one would do. So, there was a disagreement.

  • On Unix, each line ends with a < newline >, that is, \n

  • On Windows, each line ends with a < carriage return >< line wrap >, i.e. \r\n

  • On the Mac, every line ends with enter.

  • As a direct result, a file on Unix/Mac opens on Windows and all the text becomes a single line. Windows files opened on Unix/Mac may have an extra ^M symbol at the end of each line.

Newline \n (line feed)

As the name implies, this line breaks, and the cursor moves to the front of the next line to start typing from the next line

  • Move to the next line of the current position without going back to the beginning of the line
  • The hexadecimal value is:0x0A
  • ASCII: 10

Carriage return \ R (carriage Return)

The car is the cursor, and every time you type, the car moves forward (the cursor moves to the right). Enter returns the car to its original position on the line

  • Return to the beginning of the current line without changing to the next line
  • The hexadecimal value is:0x0D
  • ASCII: 13

Reference data: www.ruanyifeng.com/blog/2006/0…

Write in the last

If you find this article beneficial to you, please like it and share it with more people who need it!

Welcome to pay attention to “Quanzhandao road” and wechat official account “Quanzhandao Road”, get more good articles and free books!
If you need [Baidu] & [Bytedance] & [JINGdong] & [Ape Tutoring], please leave a message, you will enjoy VIP speed push service ~

Past oliver

Deep and shallow copies of the front end

Chrome Developer Tools to Improve development efficiency

Create a personalized Github profile

Implementation of wechat JS API payment

The interviewer asks you<img>What would you say about the element

Special JS floating-point number storage and calculation

Long [word] baidu and good interview after containing the answer | the nuggets technology essay in the future

Front end practical regular expression & tips, all throw you 🏆 nuggets all technical essay | double festival special articles

A detailed explanation of the unpopular HTML tabIndex

A few lines of code teach you to solve the wechat generated posters and two-dimensional code

Principle of Vue3.0 Responsive data: ES6 Proxy

Make the interviewer fall in love with you

How to draw a fine line gracefully

[3 minutes] Front-end performance optimization -HTML, CSS, JS parts

Front-end performance Optimization – Page loading speed optimization

Front-end Performance Optimization – Network transport layer optimization