DELPHI7的STRING默认是ANSI编码,加载UNICODE编码格式的TXT显示为乱码,解决方法如下:
procedure TForm1.Button1Click(Sender: TObject);
var
F:TFileStream;
S:WideString;
I:Integer;
FileName:string;
begin
FileName := ExtractFilePath(Application.ExeName)+'20151214003.txt';
F:=TFileStream.Create(FileName,fmOpenRead);
I:=F.Size;
SetLength(S,I div 2);
F.Read(S[1],I);
F.Free;
Delete(S,1,1);
Memo1.Text:=S;
end;