Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.
Function BufToHexStr(N:Cardinal;Buf:pCharTab;Col:Byte=0;HexaWidth:Byte=0;CDef:Boolean=False;Indent:Byte=0):String;
Var
i:Integer;
Hdr,Ftr,NewL,IdtStr:String;
begin
if Buf=nil Then Exit;
IdtStr:=DupeString(' ',Indent);
NewL:=CRLF+IdtStr;
if CDef Then
begin
Result:='{ ';
Hdr:='0x';
Ftr:=' ,';
end Else
begin
Result:='';
Ftr:=' ';
Hdr:='';
end;
if HexaWidth>0 Then while (Col MOD HexaWidth)>0 do Dec(HexaWidth);
For i:=0 to N-1 do
begin
if (i>0) And (HexaWidth>0) And ((i Mod HexaWidth)=0) Then Result:=Result+Ftr;
if (Col>0) And (i>0) And ((i Mod Col)=0) Then
begin
Result:=Result+NewL;
if CDef Then Result:=Result+' ';
end;
Result:=Result+Hdr+HexaChar(Buf^[i]);
end;
if CDef Then Result:=Result+NewL+'}';
end;
Function HexaStrToBuf(Src:ANSIString;ThrowException:Boolean=False):ANSIString;
begin
For i:=1 to Length(Src) do
if Not (Src[i] IN ['0'..'9','A'..'F']) Then
begin
if ThrowException And Not (Src[i] In [' ',#13,#10]) Then Raise Exception.Create('Invalid Hexa character');
Text[i]:=' ';
end;
P:=1;
Result:='';
While P<=Length(Src) do if Src[P]=' ' Then Inc(P) Else
begin
Result:=Result+Char(StrToInt('$'+Trim(Copy(Src,P,2))));
Inc(P,2);
end;
end;
Function BufToHexStr(Src:ANSIString;Col:Byte=0;HexaWidth:Byte=0):ANSIString;
Var
i:Integer;
begin
Result:='';
if HexaWidth>0 Then while (Col MOD HexaWidth)>0 do Dec(HexaWidth);
For i:=0 to Length(Src)-1 do
begin
if (i>0) And (HexaWidth>0) And ((i Mod HexaWidth)=0) Then Result:=Result+' ';
if (Col>0) And (i>0) And ((i Mod Col)=0)
Then Result:=Result+#13#10;
Result:=Result+Format('%2.2x',[Byte(Src[i+1])]);
end;
end;
http://www.dolcevie.com/js/converter.html
without the colons (maybe spaces instead)