classes: add TStringsOption.soPreserveBOM

git-svn-id: trunk@43848 -
This commit is contained in:
ondrej 2020-01-03 10:39:53 +00:00
parent db588d64a0
commit ee18a7ee9a
2 changed files with 5 additions and 1 deletions

View File

@ -610,7 +610,7 @@ type
TStringsForEachMethod = procedure(const CurrentValue: string) of object;
TMissingNameValueSeparatorAction = (mnvaValue,mnvaName,mnvaEmpty,mnvaError);
TMissingNameValueSeparatorActions = set of TMissingNameValueSeparatorAction;
TStringsOption = (soStrictDelimiter,soWriteBOM,soTrailingLineBreak,soUseLocale);
TStringsOption = (soStrictDelimiter,soWriteBOM,soTrailingLineBreak,soUseLocale,soPreserveBOM);
TStringsOptions = set of TStringsOption;
TStrings = class(TPersistent)

View File

@ -1397,6 +1397,8 @@ begin
finally
EndUpdate;
end;
if soPreserveBOM in FOptions then
WriteBOM:=False;
end;
@ -1431,6 +1433,8 @@ begin
SetLength(Buffer,BufLen-BufDelta+BytesRead);
PreambleLength:=TEncoding.GetBufferEncoding(Buffer,AEncoding,FDefaultEncoding);
T:=AEncoding.GetAnsiString(Buffer,PreambleLength,Length(Buffer)-PreambleLength);
if soPreserveBOM in FOptions then
WriteBOM:=PreambleLength>0;
SetEncoding(AEncoding);
SetLength(Buffer,0);
SetTextStr(T);