So I created a program on Xojo(MacOS) that parses paragraphs using EndofLine. However, when I run it on a Windows operating system it doesn't parse it at all. Does Window operating systems recognize EndofLine or Chr(10)+Chr(13) in Xojo?
Xojo MacOs Vs. Windows? EndOFLine issue
166 Views Asked by Ayah Al-Harthy At
2
There are 2 best solutions below
0
On
EndOfLine is always platform dependent, so in case of Windows, its value is chr(13)+chr(10), while on macOS it's chr(10). You can reach these platform-specific values directly by using EndOfLine.Windows and EndOfLine.OSX.
To normalise the line endings in a string, you can use the ReplaceLineEndings() function.
Xojo's EndOfLine constant is indeed different depending on the platform you use it for.
You have two choices of dealing with this:
Explicitly use a platform specific constant:
The better way, especially if you import data from outside the program, e.g. when reading from a file or from a network socket, is to normalize the line delimiters for your internal use, like this:
Now, you can use EndOfLine with normalizedString, e.g. to split it into single lines:
When you write this string back, you'll automatically have it in the system's format already.
However, when you export your text to a system where you know it expects them in a certain format, convert them back to that format like this: