Search

'StringToByte'에 해당되는 글 1건

  1. 2009.05.01 Delphi - StringToByte, ByteToString

Delphi - StringToByte, ByteToString

Programming/Delphi 2009.05.01 05:52 Posted by 파란크리스마스

출처 : http://delphi.about.com/cs/adptips2002/a/bltip1002_5.htm

type
  TByteArr = array of byte;

function StringToBytes(aString: String): TByteArr;
var
  i: integer;
begin
  SetLength( Result, Length(aString)) ;
  for i := 0 to Length(aString) - 1 do
    Result[i] := ord(aString[i + 1]) { - 48} ;
end;

function BytesToString(aBytes : TByteArr): String;
begin
  Result := PChar(aBytes);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  buffer : TByteArr;
begin
  buffer := StringToByte(Edit1.Text);
  ShowMessage(ByteToString(buffer));
end;

신고


 

티스토리 툴바