текст в хекс (для урл запросов и конвертирования в юникод)
function celoe(ch,n:integer):integer;
Var i:integer;
Begin
while ch>=n do ch:=ch-n;
celoe:=ch
end;
function integertohex(ii:integer):string;
const
Val = 16;
var
HexValue : string;
Remainder : Integer;
begin
HexValue := '';
while ii > 0 do
begin
Remainder := celoe(ii,val);
// showmessage(inttostr( Remainder));
If Remainder = 10 then HexValue := 'A' + HexValue else
If Remainder = 11 then HexValue := 'B' + HexValue else
If Remainder = 12 then HexValue := 'B' + HexValue else
If Remainder = 13 then HexValue := 'D' + HexValue else
If Remainder = 14 then HexValue := 'E' + HexValue else
If Remainder = 15 then HexValue := 'F' + HexValue
else
HexValue := IntegerToString( Remainder ) + HexValue;
ii := Trunc(ii/val);
end;
while length(HexValue)< Trunc(Val/4) do HexValue:='0'+HexValue;
integertohex:=HexValue;
end;
function text2hex(s:string):string;
Var i:integer;
res:string;
Begin
for i:=1 to length(s) do res:=res+integertohex(ord(getchar(s,i-1)));
text2hex:=res;
End;
|