mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-23 05:19:27 +02:00
laz2_dom: added EncodeLesserAndGreaterThan
git-svn-id: trunk@35618 -
This commit is contained in:
parent
a8098f0d48
commit
80a893d94c
@ -851,6 +851,7 @@ const
|
|||||||
stduri_xmlns: DOMString = 'http://www.w3.org/2000/xmlns/';
|
stduri_xmlns: DOMString = 'http://www.w3.org/2000/xmlns/';
|
||||||
|
|
||||||
function StrToXMLValue(const s: string): string;
|
function StrToXMLValue(const s: string): string;
|
||||||
|
function EncodeLesserAndGreaterThan(const s: string): string;
|
||||||
|
|
||||||
// =======================================================
|
// =======================================================
|
||||||
// =======================================================
|
// =======================================================
|
||||||
@ -919,6 +920,65 @@ begin
|
|||||||
Convert(PChar(Result),NewLen);
|
Convert(PChar(Result),NewLen);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function EncodeLesserAndGreaterThan(const s: string): string;
|
||||||
|
|
||||||
|
function Convert(Dst: PChar; out NewLen: PtrUInt): boolean;
|
||||||
|
var
|
||||||
|
h: PChar;
|
||||||
|
l: Integer;
|
||||||
|
NewLength: Integer;
|
||||||
|
Src: PChar;
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
NewLength:=0;
|
||||||
|
Src:=PChar(s);
|
||||||
|
repeat
|
||||||
|
case Src^ of
|
||||||
|
#0:
|
||||||
|
if Src-PChar(s)=length(s) then
|
||||||
|
break
|
||||||
|
else begin
|
||||||
|
h:=''; l:=0;
|
||||||
|
end;
|
||||||
|
'<': begin h:='<'#0; l:=4; end;
|
||||||
|
'>': begin h:='>'#0; l:=4; end;
|
||||||
|
else
|
||||||
|
if Dst<>nil then begin
|
||||||
|
Dst^:=Src^;
|
||||||
|
inc(Dst);
|
||||||
|
end else
|
||||||
|
inc(NewLength);
|
||||||
|
inc(Src);
|
||||||
|
continue;
|
||||||
|
end;
|
||||||
|
Result:=true;
|
||||||
|
if l>0 then begin
|
||||||
|
if Dst<>nil then begin
|
||||||
|
for i:=1 to l do begin
|
||||||
|
Dst^:=h^;
|
||||||
|
inc(Dst);
|
||||||
|
inc(h);
|
||||||
|
end;
|
||||||
|
end else
|
||||||
|
inc(NewLength,l);
|
||||||
|
end;
|
||||||
|
inc(Src);
|
||||||
|
until false;
|
||||||
|
NewLen:=NewLength;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
NewLen: PtrUInt;
|
||||||
|
begin
|
||||||
|
Result:=s;
|
||||||
|
if Result='' then exit;
|
||||||
|
if not Convert(nil,NewLen) then exit;
|
||||||
|
SetLength(Result,NewLen);
|
||||||
|
if NewLen=0 then exit;
|
||||||
|
Convert(PChar(Result),NewLen);
|
||||||
|
end;
|
||||||
|
|
||||||
{ a namespace-enabled NamedNodeMap }
|
{ a namespace-enabled NamedNodeMap }
|
||||||
type
|
type
|
||||||
TAttributeMap = class(TDOMNamedNodeMap)
|
TAttributeMap = class(TDOMNamedNodeMap)
|
||||||
|
Loading…
Reference in New Issue
Block a user