Stupid an lazy workaround, probably not suitable for larger files. {$mode objfpc} {$h+} uses sysutils;
type TUCS2TextFile = file of WideChar; procedure ReadLine(var F: TUCS2TextFile; out S: UnicodeString); var WC: WideChar; begin //Assume file is opend for read S := ''; while not Eof(F) do begin Read(F, WC); if WC = WideChar(#$000A) then exit else if (WC <> WideChar(#$000D)) and (WC<>WideChar(#$FEFF {Unicode LE BOM})) then S := S + WC; end; end; var UFile: TUCS2TextFile; US: UnicodeString; begin AssignFile(UFile, 'ucs2.txt'); Reset(Ufile); while not Eof(UFile) do begin ReadLine(UFile, US); writeln('US = ',US); end; CloseFile(UFile); end. Outputs US = Line1 US = Line2 US = Line3 which is correct for my test file (Unicode LE encoding created with Notepad). -- Bart _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal