Skip to content

Commit

Permalink
Add overloaded SaveToFile function, you can set need to write BOM or …
Browse files Browse the repository at this point in the history
…not.
  • Loading branch information
vshoolgin committed Feb 27, 2015
1 parent 1a4de1e commit 2a03599
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Source/SynUnicode.pas
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ TUnicodeStrings = class(TPersistent)
procedure LoadFromFile(const FileName: WideString); virtual;
procedure LoadFromStream(Stream: TStream); virtual;
procedure Move(CurIndex, NewIndex: Integer); virtual;
procedure SaveToFile(const FileName: WideString); virtual;
procedure SaveToFile(const FileName: WideString); overload; virtual;
procedure SaveToFile(const FileName: WideString; WithBOM: Boolean); overload; virtual;
procedure SaveToStream(Stream: TStream; WithBOM: Boolean = True); virtual;
procedure SetTextStr(const Value: UnicodeString); virtual;

Expand Down Expand Up @@ -1011,6 +1012,18 @@ procedure TUnicodeStrings.SaveToFile(const FileName: WideString);
end;
end;

procedure TUnicodeStrings.SaveToFile(const FileName: WideString; WithBOM: Boolean);
var
Stream: TStream;
begin
Stream := TWideFileStream.Create(FileName, fmCreate);
try
SaveToStream(Stream, WithBOM);
finally
Stream.Free;
end;
end;

procedure TUnicodeStrings.SaveToStream(Stream: TStream; WithBOM: Boolean = True);
// Saves the currently loaded text into the given stream. WithBOM determines whether to write a
// byte order mark or not. Note: when saved as ANSI text there will never be a BOM.
Expand Down

0 comments on commit 2a03599

Please sign in to comment.