file1.txt HEX: 48 65 6C 6C 6F 20 77 6F 72 6C 64 2E
file2.txt HEX: 0C 00 00 00 48 65 6C 6C 6F 20 77 6F 72 6C 64 2E
$ file -bi file1.txt
text/plain; charset=us-ascii
$ file -bi file2.txt
application/octet-stream; charset=binary
WriteAnsiString writes the AnsiString S (i.e. 4 bytes) to the stream. This is a utility function which simply calls the Write function. The ansistring is written as a 4 byte length specifier, followed by the ansistring's content. The ansistring can be read from the stream using the ReadAnsiString function.
Thanks all for clarification. TFileStream.WriteBuffer gives me what I expeted.
You still have to think about line endings if you want the equivalent of writeln to a textfile if that is what you want.
Yes, you skip the length being written this way. But the result not a text file.
You still have to think about line endings if you want the equivalent of writeln to a textfile if that is what you want.