Zyt3x
02-02-2011, 09:52 PM
You could always make your own :)
function HexToStr(Hex : String) : String;
var
I, X, L, H : Integer;
sArr, hArr : TStringArray;
begin
Result := '';
sArr := [' ', '!', '"', '#', '$', '%', '&', '''', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~'];
hArr := ['20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '2A', '2B', '2C', '2D', '2E', '2F', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '3A', '3B', '3C', '3D', '3E', '3F', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '4A', '4B', '4C', '4D', '4E', '4F', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '5A', '5B', '5C', '5D', '5E', '5F', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '6A', '6B', '6C', '6D', '6E', '6F', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '7A', '7B', '7C', '7D', '7E'];
L := Length(Hex);
H := High(hArr);
for I := 0 to L do
if I mod 2 <> 0 then
for X := 0 to H do
if Hex[I] + Hex[I+1] = hArr[X] then
Result := Result + sArr[X];
end;
function StrToHex(Str : String) : String;
var
I, X, L, ArrH : Integer;
sArr, hArr : array of String;
begin
Result := '';
sArr := [' ', '!', '"', '#', '$', '%', '&', '''', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~'];
hArr := ['20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '2A', '2B', '2C', '2D', '2E', '2F', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '3A', '3B', '3C', '3D', '3E', '3F', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '4A', '4B', '4C', '4D', '4E', '4F', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '5A', '5B', '5C', '5D', '5E', '5F', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '6A', '6B', '6C', '6D', '6E', '6F', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '7A', '7B', '7C', '7D', '7E'];
L := Length(Str);
ArrH := High(sArr);
for I := 1 to L do
for X := 0 to ArrH do
if Str[I] = sArr[X] then
Result := Result + hArr[X];
end;
function BinaryToHex(Bin : String) : String;
var
I, L : Integer;
begin
Result := '';
L := Length(Bin);
for I := 1 to L do
if I mod 4 = 1 then
case Bin[I] + Bin[I+1] + Bin[I+2] + Bin[I+3] of
'0000': Result := Result + '0';
'0001': Result := Result + '1';
'0010': Result := Result + '2';
'0011': Result := Result + '3';
'0100': Result := Result + '4';
'0101': Result := Result + '5';
'0110': Result := Result + '6';
'0111': Result := Result + '7';
'1000': Result := Result + '8';
'1001': Result := Result + '9';
'1010': Result := Result + 'A';
'1011': Result := Result + 'B';
'1100': Result := Result + 'C';
'1101': Result := Result + 'D';
'1110': Result := Result + 'E';
'1111': Result := Result + 'F';
end;
end;
function HexToBinary(Hex : String) : String;
var
I, L : Integer;
begin
Result := '';
L := Length(Hex);
for I := 1 to L do
case Hex[I] of
'0': Result := Result + '0000';
'1': Result := Result + '0001';
'2': Result := Result + '0010';
'3': Result := Result + '0011';
'4': Result := Result + '0100';
'5': Result := Result + '0101';
'6': Result := Result + '0110';
'7': Result := Result + '0111';
'8': Result := Result + '1000';
'9': Result := Result + '1001';
'A': Result := Result + '1010';
'B': Result := Result + '1011';
'C': Result := Result + '1100';
'D': Result := Result + '1101';
'E': Result := Result + '1110';
'F': Result := Result + '1111';
end;
end;
function StrToBinary(Str : String) : String;
begin
Result := HexToBinary(StrToHex(Str));
end;
function BinaryToStr(Bin : String) : String;
begin
Result := HexToStr(BinaryToHex(Bin));
end;
function IntToBinary(Int : Integer) : String;
begin
Result := StrToBinary(IntToStr(Int));
end;
function BinaryToInt(Bin : String) : Integer;
begin
Result := StrToIntDef(BinaryToStr(Bin), -1);;
end;
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.