Rs.ClipboardText removes line breaks

If I have a multiline text string in Python and I use rs.ClipboardText to copy it to the clipboard, when pasted to a text editor, it has lost all the line breaks. In the debugger I still see the line breaks, though. Is this a bug in the method, or is there some sort of Windows clipboard function limitation happening here?

Thx, --Mitch

Yes, it’s a Windows vs. Python line-break-character issue. If you paste it into Emacs you have the line breaks, or you may try wordpad if you don’t have Emacs.

As a quick workaround you can do this:

rs.ClipboardText(mytext.replace("\n", "\r\n"))

Hope this helps…

Don’t know if there is a more general or more elegant solution. For reading text files in Python there is a “universial newline” option (might be on by default) that recognizes all (well: Unix, Mac, Windows) sorts of newline characters. I just mention this as a possible starting point for further investigations.

Regards, Gero.

1 Like

I was just looking into that and in testing, using "\r\n" while creating the string directly seems to work OK in both Python and Windows.

Thanks, --Mitch