Delphi - TEncoding.Unicode.GetString

Programming/Delphi 2014/10/22 01:04 Posted by 파란크리스마스

출처 : Delphi - Http POST call
TStream.ReadBuffer Method
TEncoding.GetString Method (TBytes)

procedure TForm1.Button2Click(Sender: TObject);
var
  tmpBuffer, Buffer: TBytes;
  LFileStream: TFileStream;
  test : String;
begin
  //
  LFileStream := TFileStream.Create(Path + 'test.smi', fmOpenRead);

  try
    Memo1.Lines.BeginUpdate;

    // Read file into buffer
    SetLength(Buffer, LFileStream.Size);
    LFileStream.ReadBuffer(Buffer[0], Length(Buffer));

    SetLength(tmpBuffer, Length(Buffer)-2);
    CopyMemory(tmpBuffer, @Buffer[2], Length(Buffer)-2  );

    test := TEncoding.Unicode.GetString(Buffer);
    Memo1.Lines.Add(test);
  finally
    Memo1.Lines.EndUpdate;
    LFileStream.Free;
  end;
end;




 

티스토리 툴바