DELPHI7加载UNICODE编码格式的TXT显示为乱码的解决方法
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;
本文来自博客园,作者:{咏南中间件},转载请注明原文链接:https://www.cnblogs.com/hnxxcxg/p/5062412.html