This content is not available in your preferred language.

The content is shown in another available language. Your browser may include features that can help translate the text.

Difference Between Carriage Return, Line Feed and End of Line Characters

Updated Mar 7, 2019

Reported In

Software

  • LabVIEW

Issue Details

Putting a Carriage Return, Line Feed, or End of Line character into my strings in LabVIEW seems to all do the same thing. What is the difference between these three characters?

Solution

All three of these characters are ASCII representations for the end of a line. With regards to strings, LabVIEW implements the same functionality for all three: It will end the current line of a string, and start a new one.

However at the operating system level, they are treated differently.

 The Carriage Return ("CR") character (0x0D, \r) moves the cursor to the beginning of the line without advancing to the next line. This character is used as the new line character in Commodore and Early Macintosh operating systems (Mac OS 9 and earlier).

 The Line Feed ("LF") character (0x0A, \n) moves the cursor down to the next line without returning to the beginning of the line. This character is used as the new line character in Unix based systems (Linux, macOS X, Android,etc).

 The End of Line ("EOL") character (0x0D0A, \r\n) is actually two ASCII characters and is a combination of the CR and LF characters. It moves the cursor both down to the next line and to the beginning of that line. This character is used as the new line character in most other non-Unix operating systems, including Microsoft Windows and Symbian OS.

Additional Information

To convert line endings programmatically, use LabVIEW's Normalize End Of Line.vi.It converts CR, LF, and EOL characters to the character you specify, uses the current operating system's default character in case you do not specify one.


Serial connections like RS-232 often use termination characters like CR (0x0D, \r) or LF (0x0A, \n) as well. Use e.g. VISA Configure Serial Port to define the termination character your device expects. Sending the wrong termination character will often break your connection.

WAS THIS ARTICLE HELPFUL?

Not Helpful