I'm having some issues with TFileStream.WriteAnsiString in that I am using it in two programs for writing text to output files. In both cases, I am getting additional data around my strings (Unicode in fact).
My usgae is as simple as
var
MyString : string;
begin
MyString := 'Hello';
MyFS.WriteAnsiString(MyString);
end;
Should I be doing something extra when using it, like specfiying a length or calling SetLength or something? I ask because the documentation is confusing me (
http://www.freepascal.org/docs-html/rtl/classes/tstream.writeansistring.html) and I think perhaps related to the problem where it says :
"The ansistring is written as a 4 byte length specifier, followed by the ansistring's content. " For example, my code segment
https://github.com/tedsmith/quickhash/blob/master/unit2.pas#L1159 here works in that the HTML output is written OK, but in the finished HTML file, there are loads of seemingly random values added just after fsHTMLOutput.WriteAnsiString(strTableHeader); The more content my tables hold, the more of these values exist. So with a large list of thousands of files, my HMTL file has hundreds of lines of Unicode values embedded above the table. So it seems to be adding values for every iteration of the for loop. To see what I mean in a practical sense, try downloading the program (
https://sourceforge.net/projects/quickhash/files/v2.6.9/), click on the "Compare Directories" tab, choose two folders with more or less the same files in them and then click "Save to File" when finished and open the HTML file.