* AlwaysQuote added (bug ID 31126)

git-svn-id: trunk@35333 -
This commit is contained in:
michael 2017-01-25 22:37:33 +00:00
parent 0013769c4b
commit f0a8355b84
2 changed files with 15 additions and 6 deletions

View File

@ -603,6 +603,7 @@ type
FDefaultEncoding: TEncoding;
FEncoding: TEncoding;
FSpecialCharsInited : boolean;
FAlwaysQuote: Boolean;
FQuoteChar : Char;
FDelimiter : Char;
FNameValueSeparator : Char;
@ -707,6 +708,7 @@ type
property Encoding: TEncoding read FEncoding;
property LineBreak : string Read GetLineBreak write SetLineBreak;
Property StrictDelimiter : Boolean Read FStrictDelimiter Write FStrictDelimiter;
property AlwaysQuote: Boolean read FAlwaysQuote write FAlwaysQuote;
property QuoteChar: Char read GetQuoteChar write SetQuoteChar;
Property NameValueSeparator : Char Read GetNameValueSeparator Write SetNameValueSeparator;
property ValueFromIndex[Index: Integer]: string read GetValueFromIndex write SetValueFromIndex;

View File

@ -200,7 +200,8 @@ Var
p : pchar;
BreakChars : set of char;
S : String;
doQuote : Boolean;
begin
CheckSpecialChars;
result:='';
@ -213,11 +214,16 @@ begin
For i:=0 to count-1 do
begin
S:=Strings[i];
p:=pchar(S);
//Quote strings that include BreakChars:
while not(p^ in BreakChars) do
inc(p);
if (p<>pchar(S)+length(S)) then
doQuote:=FAlwaysQuote;
If not DoQuote then
begin
p:=pchar(S);
//Quote strings that include BreakChars:
while not(p^ in BreakChars) do
inc(p);
DoQuote:=(p<>pchar(S)+length(S));
end;
if DoQuote then
Result:=Result+QuoteString(S,QuoteChar)
else
Result:=Result+S;
@ -722,6 +728,7 @@ begin
FDefaultEncoding:=TEncoding.Default;
FEncoding:=nil;
FWriteBOM:=True;
FAlwaysQuote:=False;
end;
Function TStrings.Add(const S: string): Integer;