[fpc-pascal] Creating text files with TFileStream
Vincent Snijders
vsnijders at vodafonevast.nl
Fri Oct 23 12:18:54 CEST 2009
Graeme Geldenhuys schreef:
> 2009/10/23 Gerard N/A <gerardusmercator at gmail.com>:
>> Could it be that the length indicator bytes of the string are written
>> to the stream?
>
> Ah, looking at the .WriteAnsiString() implementation, you seem to be
> 100% correct.
>
> Procedure TStream.WriteAnsiString (const S : String);
> Var L : Longint;
> begin
> L:=Length(S);
> WriteBuffer (L,SizeOf(L));
> WriteBuffer (Pointer(S)^,L);
> end;
>
>
> That function is then very deceiving - by doing something extra to
> what the method name suggests. Why is the writing of the string length
> as a prefix needed?
Otherwise you cannot read it back. :-)
Vincent
More information about the fpc-pascal
mailing list