I am trying to read data from a .log file and process its contents. The log file is created by another application. When I use the readln command in Delphi and display the contents of the file in a memo, I only get the one line of data (ÿþI) from a file with over 6000 lines of data.
procedure TForm1.Button1Click(Sender: TObject);
Var
F : TextFile;
s : string;
begin
AssignFile(F, 'data.log');
Reset(F);
while not Eof(F) do
begin
Readln(F, s);
Memo1.Lines.Add(s);
end;
end;
Does anyone know what the problem might be?
As Michael said, you are dealing with a UTF-16 encoded file, so you will have to load and decode it manually. There are various
WideString-basedTStringList-like classes floating around online, or Borland has its own implementation in theWideStringsunit, try using one of them instead of Pascal file I/O, eg:Or:
Alternatively, install a copy of TNTWare or TMS, which both have Unicode-enabled components. Then you should be able to just
LoadFromFile()the .log file directly into whicher Unicode Memo component you chose to use.