|
function ConvertInteger(Source, Len: Integer): String;
var
i: Integer;
begin
Result :='';
if Len> SizeOf(Source) then
Exit;
for i := 1 to Len do
begin
Result := Chr(Source and $FF) + Result;
Source := Source shr 8;
end;
end;
//Restore the protocol integer (multiple bytes in network byte order) to an integer
function RevertInteger(Source: String): Integer;
var
i, Len: Integer;
n: Int64;
begin
Source := Copy(Source, 1, SizeOf(Result));
Result := 0;
n := 0;
i := 1;
Len := Length(Source);
while i <= Length(Source) do
begin
n := n shl 8 + Ord(Source[i]);
Inc(i);
end;
if n> Power($100, Len) / 2-1 then
n := n-Floor(Power($100, Len));
Result := n;
end;
//Why does LZ want this? ? ? This conversion is easily out of bounds |
|