diff --git a/packages/rtl/classes.pas b/packages/rtl/classes.pas index 26b0e14..55ccb74 100644 --- a/packages/rtl/classes.pas +++ b/packages/rtl/classes.pas @@ -1541,26 +1541,6 @@ end; { //!! is used to mark unsupported things. } -(* -Function QuoteString (Const S : String; Const Quote : String) : String; -Var - I,J : Integer; -begin - J:=0; - Result:=S; - for i:=1 to length(s) do - begin - inc(j); - if S[i]=Quote then - begin - Insert(Quote,Result,J); - inc(j); - end; - end; - Result:=Quote+Result+Quote; -end; -*) - { For compatibility we can't add a Constructor to TSTrings to initialize the special characters. Therefore we add a routine which is called whenever diff --git a/packages/rtl/sysutils.pas b/packages/rtl/sysutils.pas index c81f2ae..605d805 100644 --- a/packages/rtl/sysutils.pas +++ b/packages/rtl/sysutils.pas @@ -208,9 +208,10 @@ Type TStringReplaceFlags = set of TStringReplaceFlag; TReplaceFlags = TStringReplaceFlags; -function StringReplace(aOriginal, aSearch, aReplace : string; Flags : TStringReplaceFlags) : String; -function QuoteString(aOriginal : String; AQuote : Char) : String; -function QuotedStr(const s: string; QuoteChar : Char = ''''): string; +function StringReplace(aOriginal, aSearch, aReplace: string; Flags: TStringReplaceFlags): String; +function QuoteString(aOriginal: String; AQuote: Char): String; +function QuotedStr(const s: string; QuoteChar: Char = ''''): string; +function DeQuoteString(aQuoted: String; AQuote: Char): String; function IsDelimiter(const Delimiters, S: string; Index: Integer): Boolean; function AdjustLineBreaks(const S: string): string; function AdjustLineBreaks(const S: string; Style: TTextLineBreakStyle): string; @@ -2083,6 +2084,31 @@ begin Result:=QuoteString(S,QuoteChar); end; +function DeQuoteString(aQuoted: String; AQuote: Char): String; +var + i: Integer; +begin + Result:=aQuoted; + if TJSString(Result).substr(0,1)<>AQuote then exit; + Result:=TJSString(Result).slice(1); + i:=1; + while i<=length(Result) do + begin + if Result[i]=AQuote then + begin + if (i=length(Result)) or (Result[i+1]<>AQuote) then + begin + Result:=TJSString(Result).slice(0,i-1); + exit; + end + else + Result:=TJSString(Result).slice(0,i-1)+TJSString(Result).slice(i); + end + else + inc(i); + end; +end; + function IsDelimiter(const Delimiters, S: string; Index: Integer): Boolean; begin Result:=False;