Thank you Emile for taking the time to post, all valid points and good recommendations.
[quote=409207:@Emile Schwarz]Remember:
You put data in the Clipboard, but you cannot do anything on how applications (Word, your example) or the OS (macOS here) deal with the Clipboard.[/quote]
Correct, I just found a way to put RTF data into the clipboard for other apps to use. Thanks to Jonathan I found out that it was easier to do just be using "RTF " and not âRTFâ, so no need of âpublic.rtfâ (but that works too). If the other apps in macOS can handle the RTF copied from Styled TextArea is another issue, some may fail.
[quote]Also, taking a Microsoft application for your test is not really a good example (this is a 30 years experiment result).
You better use a pannel of current versions (Mojave) of applications: differences can occured inside of the same application thru theiits versions.[/quote]
Iâm not a professional programmer, so testing Mojave is not a priority. I understand what you are saying, I dedicated many hours documenting a âbugâ that was macOS 10.12.6 problem and not Xojoâs. When I was able to test the code with High Sierra I was not able to reproduce the problem while with Sierra I can reproduce it at will.
Yes, test is how I understand things and once I understand them I can learn/remember things more easily. Also I can find other ways to do things if the âas designedâ is not the same as âwhat I expectâ.
ReplaceLineEndings is a great thing to have but I think that also helps to keep some bugs without fixing. More about this on next paragraph.
[quote]Return is not always Chr(13); End of Paragraph is not Return (even if visually it can looks the same.
Here I will use Word to explain: in Word you had (still have ?) a command to display the invisible characters. In a document, add a Return, an end of paragraph character and look at their visual look: they are different. (their hex value too).[/quote]
It was hard for me to understand all the EndOfLine options, mostly because I never knew there were several and because I canât see them as I can see the character âaâ. After reading EndOfLine docs I expected EndOfLine on mac to be Chr(10), at least most of the time. To my surprise, if I use Xojoâs Clipboard to put Chr(10) there it always return as Chr(13). Thanks to my tests and ShowClipboards app, I found that this code:
Dim c as New Clipboard
c.Text = "1" + EndOfLine + "2"
will create 2 clipboard objects, âutf8â and âTEXTâ. utf8 has the expected chr(10) as EndOfLine and TEXT has chr(13).
utf8 is also named public.utf8-plain-text and TEXT com.apple.traditional-mac-plain-text
I expected this code to get chr(10) but always got back chr(13) on mac (Windows and Linux work ok):
Dim s As String = c.Text
I guess Xojoâs mac clipboard check the TEXT value and not the utf8 value. I reported that with a Feedback case and I know they can close it âas designedâ, but know is not a problem for me, because I know that it creates the utf8 value on the clipboard, so I can get the value from there, just have to change the previous code to:
Dim s As String = DefineEncoding(c.RawData("utf8"), Encodings.UTF8)
this way I get chr(10), the same EndOFLine copied originally to the clipboard. So even if Xojo say âas designedâ I can change my code to make it work as I expect.
This will work on Windows, Linux and Mac:
Dim c As New Clipboard
c.Text = "1" + EndOfLine + "2"
#if TargetMacOS Then
Dim s As String = DefineEncoding(c.RawData("utf8"), Encodings.UTF8)
#Else
Dim s As String = c.Text
#Endif
Mac, expected chr(10) and now I get chr(10) instead of chr(13).
Linux, expected chr(10), chr(10) returned
Windows, expected chr(13)+chr(10), and I get that.
If Xojo say, yes, newer macOS use chr(10) and we should check utf8 instead of TEXT, then great, I can use c.Text directly, if not, then there is a way.
I may never use the clipboard in one of my apps, and just use the systemâs copy/paste, but because I want to learn more about things that Xojo offer, thatâs why my interest to learn about the clipboard, line endings, #If and other things. If I found something that I donât understand/expect, then I do tests until it make sense or report my findings so Xojo can decide if things are working like they want or they could change something to make it work more like I initially expected to work.