0

I am now aware of the theoretical explanation of CR & LF. Carriage Return (CR): moving to the begining of the line without progressing forward. Line Feed (LF): moving a line forward or next line.

But i am not able to visualize the below statements.

Windows applications store a new line as: carriage return and line feed (CR+LF).
Unix and Mac OSX uses LF.
Old Mac systems uses CR.
XML stores a new line as LF.

Can anyone show an example on this?

OK999
  • 1,353
  • 2
  • 19
  • 39
  • The differences between CR and LF are historic artifacts when a primary display was a line printer, where CR and LF had different effects. Some teriminals try to honor that, other get confused. Its really not worth spending time on. Just write your code to use the correct line termination for your target OS and move on ;-) . Good luck. – shellter Apr 04 '17 at 19:24
  • In any case, StackOverflow is about helping people fix their programming code. If you have a specific/reproducible problem, then post a new Q with sample input, expected output, current code/output and error messages. Please read http://stackoverflow.com/help/how-to-ask , http://stackoverflow.com/help/dont-ask , http://stackoverflow.com/help/mcve and take the [tour](http://stackoverflow.com/tour) before posting more Qs here. Good luck. – shellter Apr 04 '17 at 19:24
  • I am trying to find any possible deviations, as i see these cr and lf stuff spitted on the git bash, while i push certain files into the git repo – OK999 Apr 04 '17 at 19:37
  • Then your Q is unclear. maybe `cat -vet file` can help. it will show CR as `$` and LF as `^M`. Again, we need a reproducible problem in code in order to help. And sorry but "can anyone show an example on this" is a request for tutorial, which is also off-topic here. Sorry and good luck. – shellter Apr 04 '17 at 19:44
  • I'm not sure there's anything to visualize. Different operating systems have different standards for how end-of-line is represented when plain text is stored in a file. Remember, the file is just a series of bytes, the meaning of those bytes depends on the application. By convention, a Windows application that is reading a text file will interpret a 13 (CR) followed by a 10 (LF) as meaning the end of a line, a Linux application will interpret a 10 (LF) by itself as meaning the end of a line, an old Mac application will interpret a 13 (CR) by itself as meaning the end of a line. – Harry Johnston Apr 04 '17 at 21:39

0 Answers0