Serial.println cause an extra CR+LF line when Monitor contents copied to a texteditor

JanB

New member
A simple program outputs THREE 'Serial.println' lines to the Serial Monitor.
Using an Arduino Uno, three lines are shown and when 'Copy/Pasted' into a Text Editor (Notepad++), there are still three lines.
Using a Teensy 3.5, same three lines are shown, but when 'Copy/Pasted' into the Text Editor, there are instead SIX lines! An extra, empty line (only CR+LF) is added after each "text" line! So, they don't show on the Serial Monitor, only when 'Copy/Pasted'!
 
I've found a way to avoid the extra CR+LFs!
If I add a single LF character at the end of the string, moving the Null String byte (ASCII Zero) 1 step to the "right", and then use 'Serial.print' rather than 'Serial.println', will still show correctly on the Teensy Monitor AND won't create the extra CR+LFs when 'Copy/Pasted'...

BUT, I do think that these extra CR+LFs are a Serial Monitor BUG, rather than an "undocumented(?) feature"!
 
The workaround in post #2 is what I tend to do. Add '\n' to the string or .print('\n');

@KurtE made a point of this some time back. It only happens on copy from IDE SerMon - at least Teensy SerMon - not all Serial Monitor programs like TyCommander. It does not seem to happen on MAC.

It is because println() sends both CR and LR chars and they are maintained on copy to clipboard
 
Yes, it’s a bug. This was one of many small details which were not clear (at least to me) in the Java documentation when I wrote the FifoDocument class that speeds up the serial monitor to handle sustained max speed printing from Teensy 4.0. Now I know the rest of the system expects \r chars to be filtered out. Planning to fix this eventually, but the reality is I consider this bug to be low priority.
 
Back
Top