Difference between Line Termination or Endings in Windows '/r/n' and UNIX '/n'. Different types of Line systems.

Hi Everyone in todays post, I will explore the Line Endings or End of Line (EOL) in different system and how to identify them -

First thing to note is -
0d stands for Carriage Return - CR
0a stands for Line Feed - LF

In Windows System when we press ENTER KEY a new line is represented with Hex control character of 0d and 0a.

In UNIX system, when we press ENTER KEY a new line is represented with Hex control character of 0a.

OS X also uses a single LF character, and classic Mac operating system used a single CR character for line breaks

Here (in Windows) we will use the below Text to create a file
First Line then Enter Key pressed
Second Line then Enter Key pressed


HEXADECIMAL View of Text File Created in WINDOWS system 

HEXADECIMAL View of Text File Created in WINDOWS system
 As we can see, for the file created in Windows system new line is represented by the characters 0d and 0a which is Carriage return and Line Feed

HEXADECIMAL View of Same Text File Created in UNIX system
 
HEXADECIMAL View of Text File Created in UNIX system
As we can see, for the file created in UNIX system new line is represented by the character 0a which is Line Feed


History – During the era of Typewriter 
 
LF moved the paper up (but kept the horizontal position identical) and
CR brought back the "carriage" so that the next character typed would be at the leftmost position on the paper (but on the same line).
CR+LF was doing both, i.e. preparing to type a new line.

No comments: