When I write a file using Delphi it's on a Windows machine and the text files it puts out work fine on windows. When I use it on a Mac though it's expecting the formatting to be a bit different. On Mac the newline is different and it can't always read the Windows files.
How can I make my files readable by mac programs?
There is no universal newline for all operating systems. You have to use linefeed on some, carriage return on others, and both on some others.
Most text editors can handle multiple kinds of line endings - check your documentation. There are also plenty of utilities that can translate line endings for you.
Instead of "universal newline" you could write a "universal format" such as JSON, XML, PDF etc depending if your output is destined to be used as data for another program or a report document to be read by humans.
In the system unit there is a global variable DefaultTextLineBreakStyle set based on the OS. It can be tlbsLF or tlbsCRLF. If it is tlbsLF, use #10, if it is tlbsCRLF use #13 #10.
From system:
I just wonder why it's a var and not a const.
Very old thread that is still very relevant. The easiest way to handle this and other situations when you get text data from different operating is to start by normalise the information first. This is Javascript but you should be able to change it into any other language easy enough.
In most languages it could be translated into this (but in JS it will just replace the first occurance.)
It will simply make sure that newline is represented by "\n" , if you want for instance windows format you simply add after the above..
The simple fact is that it is different for all operating systems. There is no "universal" newline. The best you can do is be aware of the differences.
http://en.wikipedia.org/wiki/Newline
Accordingly you have to write
$0D
for MacOS up to version 9 and$0A
for MacOS X.