[fpc-pascal]TStream.WriteAnsiString
Brian Grainger
granam at shaw.ca
Wed Aug 21 03:54:20 CEST 2002
Greetings.
I'm having a problem with TStream.WriteAnsiString. My apologies if this has
been answered previously, I haven't seen it in the archive.
I'm using the procedure to write an ansistring of valid XML to a file. The
problem is that the procedure also writes the length of the ansistring as a
variable length binary field at the start of the string. The XML parser
chokes on what it thinks is some kind of binary gibberish at the very start
of the file.
Procedure TStream.WriteAnsiString (S : String);
Var L : Longint;
begin
L:=Length(S);
WriteBuffer (L,SizeOf(L)); <---- This is the problem.
WriteBuffer (Pointer(S)^,L);
end;
What was the reason for this design decision? I can work around it by
writing my own similar procedure which doesn't write the string length
bytes, but it would be nicer to use a standard routine from the library.
Regards,
Brian
More information about the fpc-pascal
mailing list