Registriert seit: 26. Mai 2004
3.159 Beiträge
|
Re: HELP: JAVA TO PASCAL/DELPHI
23. Jun 2006, 23:45
Try this code - there is no guaranty that it's right
Delphi-Quellcode:
function decodeStringF2(QStringBuffer : TStringList; s: String): TStringList;
var
i, k, j, l : Integer;
c : Char;
Buffer : TStringList;
begin
Buffer := QStringBuffer;
if(s <> '') then
begin
i := length(s);
// i had to replace the for because i can't change an counter in a for
j := 1; // Index in a String is different - in Delphi it starts with 1
while j < i do
begin
c := s[j];
if c = '&' then
begin
if (i < j+5) then break;
k := 0;
for l := 0 to 3 do
begin
inc(j);
k := k*16;
k := k + StrToInt(s[j]) - 65; // Here you habe to be careful! The character here must be a number!
end;
end
else begin
Buffer.Append(c);
end;
inc(j);
end;
end;
Result := Buffer;
end;
function decodeStringF1(s: String): String;
var
Buffer : TStringList;
begin
Buffer := TStringList.Create;
Buffer := decodeStringF2(Buffer, s);
Result := Buffer.Text;
end;
// Edit
Deleted some test-code!
»Remember, the future maintainer is the person you should be writing code for, not the compiler.« (Nick Hodges)
|