5

There is something I don't understand about serial monitor.

As far as I know the Newline option is \n.

The Carriage return option is \r\n.

But does that make the Both NL & CR option \n\r\n?

2 Answers 2

8

Newline is \n

Carriage Return is \r

Both NL & CR is \r\n

1
  • It would be wonderful if this could be called "CR & NL" (note the sequence) or maybe just say \r\n. Because when you read "Both NL & CR" you then scratch your head and say "hm, does this actually mean \n\r". Feb 18 at 0:47
3

"Both" means 1 Carriage Return and 1 Newline (formerly known as "Line Feed"). Our present day "standards" are descended from mechanical teletypes that used those separate codes for the two separate mechanical functions: Returning the print carriage to the left side of the page, and scrolling the paper up one line.

The DOS/Windows world adopted the teletype standard (both) as is.

The unix world dropped the carriage return as unnecessary, letting a single character stand for the end of a line, and more modern hardware (or its software drivers) could figure out what to do for the particular device.

The Apple world chose Carriage Return for its standard back in the mists of time, dropping it in later years for a selectable end-of-line sequence where appropriate, but more usually using the unix standard once it's OSes became hosted on unix.

1
  • Baudot had separate CR LF. It was common to use CR and duplicate part of a line to get "Bold" characters.
    – Milliways
    Apr 8, 2016 at 1:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.