ReplaceLineEndings from ClipBoard text with EndOfLine.Windows

It is a so strange bug that I ask myself if I’m not silly.

Dim TampText, TampTab(-1) as String
Dim PressPap as New Clipboard

If Keyboard.AsyncAltKey and PressPap.TextAvailable Then
  TampText = PressPap.Text
Else
  TampText = "Line 1" + EndOfLine.Windows + "Line 2" + EndOfLine.Windows + "Line 3"
  MessageBox "copy the 3 lines below on the clipboard :" + EndOfLine + TampText
End If
TampText = TampText.ReplaceLineEndings(EndOfLine.macOS)
TampTab = TampText.Split(EndOfLine.macOS)
MessageBox "Count of items = " + str(TampTab.Count) + EndOfLine + String.FromArray(TampTab, "<-->")

Paste that in a button and launch the app

  • Click button without pressing Alt key
  • Copy the 3 lines (1 , 2 and 3)
  • A messagebox appears counting 3 items which is true
  • Click again the button holding down the Alt key
  • A messagebox appears counting 5 items -> each lineendings are double

I’m doing this test on Mac Mojave. I know EndOfLine.Windows = 0D + 0A but it shouldn’t do that result or am i silly ?

I followed your instructions, ran the project, and I see no bug here. Apparently you selected all the lines when you copied the text to the clipboard, or you copied some other text to the clipboard unintentionally in between. If you are running any other app in the background simultaneously which uses the clipboard that could also be interfering with your test. Anyway, there is no bug here.

Thomas, I followed your instructions and get the exact same results as you.
First this:

And using ALT this:

0D0A is changed to 0D0D

Thomas, change:

If Keyboard.AsyncAltKey and PressPap.TextAvailable Then TampText = PressPap.Text Else
to

If Keyboard.AsyncAltKey and PressPap.TextAvailable Then TampText = PressPap.RawData("utf8").DefineEncoding(encodings.UTF8) Else

Thank you for your checking and the tips. I think I should fill a bug report as it shouldn’t do that.

Yes, it is a bug in Xojo, for some reason is reading the Clipboard, when using clipboard.Text, as 0D0D instead of 0D0A

This bug seems to be still there in Xojo 2020r1.

The feedback case still ‘Verified’, it needs to say ‘Fixed and Verified’ to expect to be fixed on a release:
<https://xojo.com/issue/53606>

Some bugs get fixed very fast, others not much. Because this bug has a workaround for Mac it may take time to get fixed.