[fpc-pascal] TStringStream.DataString returns garbage?

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Fri Feb 3 09:39:39 CET 2012



On Fri, 3 Feb 2012, Marco van de Voort wrote:

> In our previous episode, Jorge Aldo G. de F. Junior said:
>> I would vote for a new function on all stream types to allow writing
>> strings in the expected way
>
> There is no default way to stream a string.
>
> On textfiles you only stream contents, on binary files usually a length
> field (which can be 1,2,4 bytes depending on format) + contents.

The latter exists:

http://www.freepascal.org/docs-html/rtl/classes/tstream.writeansistring.html

We could make an optional parameter "AsText : Boolean = False" which would
then write the former.

Downside is that the 'read' operation will not be able to read the text form.

Michael.



More information about the fpc-pascal mailing list