[fpc-devel] TStrings and BOM

Dmitry Boyarintsev skalogryz.lists at gmail.com
Thu Jan 2 01:13:16 CET 2020


On Wed, Jan 1, 2020 at 6:51 PM Ondrej Pokorny <lazarus at kluug.net> wrote:

> If you want to simplify a call, use a class helper:
>
> TStringsHelper = class helper for TStrings
> ...
> procedure TStringsHelper.SaveToFileWithBOM(aFileName: string);
> begin
>    WriteBOM := True;
>    SaveToFile(aFileName);
> end;
>

a bit more accurate version:

procedure TStringsHelper.SaveToFileWithBOM(aFileName: string);
var  prevBom : Boolean;
begin
  prevBom := WriteBOM ;
  try
    WriteBOM := True;
    SaveToFile(aFileName);
  finally
    WriteBom := prevBom;
  end;
end;  :
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20200101/be1d0fc8/attachment.html>


More information about the fpc-devel mailing list