csvdocument: some more optimizations
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1478 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
d4da5d7108
commit
32aa697b43
@ -188,8 +188,8 @@ const
|
|||||||
LF = #10;
|
LF = #10;
|
||||||
HTAB = #9;
|
HTAB = #9;
|
||||||
SPACE = #32;
|
SPACE = #32;
|
||||||
WhitespaceChars: TSysCharSet = [HTAB, SPACE];
|
WhitespaceChars = [HTAB, SPACE];
|
||||||
LineEndingChars: TSysCharSet = [CR, LF];
|
LineEndingChars = [CR, LF];
|
||||||
|
|
||||||
function ChangeLineEndings(const AString, ALineEnding: String): String;
|
function ChangeLineEndings(const AString, ALineEnding: String): String;
|
||||||
var
|
var
|
||||||
@ -420,15 +420,20 @@ end;
|
|||||||
function TCSVBuilder.QuoteCSVString(const AValue: String): String;
|
function TCSVBuilder.QuoteCSVString(const AValue: String): String;
|
||||||
var
|
var
|
||||||
I: Integer;
|
I: Integer;
|
||||||
|
ValueLen: Integer;
|
||||||
|
SpecialChars: TSysCharSet;
|
||||||
NeedQuotation: Boolean;
|
NeedQuotation: Boolean;
|
||||||
begin
|
begin
|
||||||
NeedQuotation := (AValue <> '') and FQuoteOuterWhitespace
|
ValueLen := Length(AValue);
|
||||||
and ((AValue[1] in WhitespaceChars) or (AValue[Length(AValue)] in WhitespaceChars));
|
|
||||||
|
|
||||||
|
NeedQuotation := (AValue <> '') and FQuoteOuterWhitespace
|
||||||
|
and ((AValue[1] in WhitespaceChars) or (AValue[ValueLen] in WhitespaceChars));
|
||||||
|
|
||||||
|
SpecialChars := [CR, LF, FDelimiter, FQuoteChar];
|
||||||
if not NeedQuotation then
|
if not NeedQuotation then
|
||||||
for I := 1 to Length(AValue) do
|
for I := 1 to ValueLen do
|
||||||
begin
|
begin
|
||||||
if AValue[I] in [CR, LF, FDelimiter, FQuoteChar] then
|
if AValue[I] in SpecialChars then
|
||||||
begin
|
begin
|
||||||
NeedQuotation := True;
|
NeedQuotation := True;
|
||||||
Break;
|
Break;
|
||||||
|
Loading…
Reference in New Issue
Block a user