Hi,
I am trying some simple code to read textfiles:
var
MyF, MyDestFile: TextFile;
MyLine: WideString;
begin
AssignFile(MyF, 'c:\temp\test.txt');
AssignFile(MyDestFile, 'c:\temp\result.txt');
try
Reset(MyF);
Rewrite(MyDestFile);
while not EOF(MyF) do
begin
ReadLn(MyF, MyLine);
WriteLn(MyDestFile, MyLine);
end;
except
Raise;
end;
end;
If my file is ANSI, I define a String variable and do "MyLine := UTF8ToUTF16(WinCPToUTF8(MyString));" to have it in my widestring.
If my file is UTF8, no explicit conversion needed. Honestly, I would have thought my code would have failed in that case.
If my file is Unicode (Little or Big Endian), the readln seems to fail (for instance, I cannot display/write in a memo my line).
I used to play with a tfilestream but as in my case reading the file line by line is important, readln made my code simplier, clearer and faster.
What am I missing?
Thanks