mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-04-13 08:39:23 +02:00
sysutils: added function DeQuoteString
This commit is contained in:
parent
aabb2c66cf
commit
8e84c3d709
packages/rtl
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user