How to get char binary code

Hello How can I get chars binary code?
ILPowerSoftAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

brunoheCommented:
try Ord(char)
0
ProbieCommented:
function GetCharCode(ch : char) : byte;
begin
 result := ord(ch);
end;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ILPowerSoftAuthor Commented:
I need to get the binary code as 0011 1010111
0
ProbieCommented:
Here is an example on how to get the binary code for an char


function raise2(v : longint; exp : byte) : longint;
var loop,t : longint;
begin
 t := v;
 if exp <> 0 then begin
  for loop := 1 to exp-1 do begin
   v := t * v;
  end;
 end else v := 1;
raise2 := v;
end;

function bytebin(v : byte) : string;
var l1,l2 : byte;
    c : word;
    st : string[8];
begin
 st := '00000000';
 l2 := 7;
 for l1 := 1 to 8 do begin
  c := raise2(2,l2);
  dec(l2);
  if (v >= c) then begin
   dec(v,c); st[l1] := '1';
  end;
 end;
 bytebin := st;
end;

function GetCharCode(ch : char) : string;
begin
 result := bytebin(ord(ch));
end;
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.