bonjour a tous,
voila mon pb : dans une appli je lis un fichier en binaire,
aprés conversion en hexadecimal, tout serait ok si les octets contenant un numéro de telephone ne soient inversés :
06 20 30 40 50 se retrouve en 60 02 03 04 05 ....
la fonction qui convertit le bin en hexa :
function Bin2HexExt(const input:string; const spaces, upcase: boolean): string;
var
loop : integer;
hexresult : string;
begin
hexresult := '';
for loop := 1 to Length(input) do
begin
hexresult := hexresult + IntToHex(Ord(input[loop]),2);
if spaces then hexresult := hexresult + ' ';
end;
if upcase then result := AnsiUpperCase(hexresult)
else result := AnsiLowerCase(hexresult);
end;
Celle qui convertit de l hexa en string :
function Hex2Str(const input:string; const spaces, upcase: boolean): string;
var
loop : integer;
hexresult : string;
strresult :string;
begin
hexresult := '';
for loop := 1 to Length(input) do
begin
hexresult := hexresult + char(input[loop]) ;
if spaces then hexresult := hexresult + ' ';
end;
if upcase then result := AnsiUpperCase(hexresult)
else result := AnsiLowerCase(hexresult);
end;
cette derniere fonctionne ok pour la partie alpha du fichier.
En 2 mots existe-t-il une routine pour inverser un octet ( de 09 vers 90 par exemple ) dans une chaine hexa ?
merci à l avance de vos réponses , j avoue que je coince !!!!!
jm30