티스토리 뷰

Programming/Delphi

Delphi - TEncoding.Unicode.GetString

파란크리스마스 2014. 10. 22. 01:04
728x90

출처 : 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;


댓글
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
글 보관함