我想将memo1控件里的内容写到log.txt文件中去,写是写进去了,可是文件里全是乱码我的代码是:      LogfilePath为日志文件的路径,已确认是正确的
var
  fhandle:integer;
  loglist:TStringList;
  i:integer;
  str:string;
begin
  loglist:=TstringList.Create;
  if not fileexists(LogfilePath) then
    filecreate(LogfilePath);
  fhandle:=fileopen(LogfilePath,fmOpenWrite);
  loglist.Text:=memo1.Lines.Text;
  fileseek(fhandle,0,2);
  for i:=0 to loglist.Count-1 do
  begin
    str:=loglist[i];
    filewrite(fhandle,str,sizeof(str));
  end;
  Fileclose(fhandle);
end;