السلام عليك:
عندي دالة تحويل string الى binary لكن لم اعرف بالضبط الخطوات التي تقوم بها
عندي دالة تحويل string الى binary لكن لم اعرف بالضبط الخطوات التي تقوم بها
كود :
function StrToStrBin(const S: string): string;
var pOutput : pChar;
pInput : ^byte;
N, LenInput : integer;
const
AtBin : array[boolean] of char = '01';
begin
LenInput := Length(S);
SetLength(Result, LenInput shl 3);
pInput := @S[1];
pOutput := pChar(result);
for N := 1 to LenInput do
begin
pOutput[0] := AtBin[(pInput^ and $80) = $80];
pOutput[1] := AtBin[(pInput^ and $40) = $40];
pOutput[2] := AtBin[(pInput^ and $20) = $20];
pOutput[3] := AtBin[(pInput^ and $10) = $10];
pOutput[4] := AtBin[(pInput^ and $08) = $08];
pOutput[5] := AtBin[(pInput^ and $04) = $04];
pOutput[6] := AtBin[(pInput^ and $02) = $02];
pOutput[7] := AtBin[(pInput^ and $01) = $01];
inc(pOutput,8);
inc(pInput);
end;

![[-]](https://delphi4arab.net/forum/D4A2020/collapse.png)