[Lazarus] StringGrid1.SaveToCSVFile - UTF-8 with BOM
Michael Van Canneyt
michael at freepascal.org
Sat Mar 10 17:25:48 CET 2018
On Sat, 10 Mar 2018, Mattias Gaertner via Lazarus wrote:
> On Sat, 10 Mar 2018 16:57:08 +0100
> Sandro Cumerlato via Lazarus <lazarus at lists.lazarus-ide.org> wrote:
>
>> Hello,
>> how can I save StringGrid content to a CSV file encoded to "UTF-8 with BOM"
>> format? (as default it is saved to "UTF-8 without BOM" format)
>
> var
> s: string;
> ms: TMemoryStream
>
> ms:=TMemoryStream.Create;
> try
> s:=UTF8BOM;
> ms.Write(s[1],length(s));
> Grid.SaveToCSVStream(ms)
> ms.Position:=0;
> ms.SaveToFile('foo.csv');
> finally
> ms.Free;
> end;
You can also just use a filestream ?
Michael.
More information about the Lazarus
mailing list