On 2019-09-04 13:39, LacaK wrote:
You may be able to improve on this using system.BlockRead.
Probably yes, but then I must read in local buffer and examine buffer
for CR/LF.
And return from my function UCS2ReadLn() only portion of string up to
CR/LF and rest of string return on next call to my
You may be able to improve on this using system.BlockRead.
Probably yes, but then I must read in local buffer and examine buffer
for CR/LF.
And return from my function UCS2ReadLn() only portion of string up to
CR/LF and rest of string return on next call to my function.
(so I must keep unpr
You may be able to improve on this using system.BlockRead.
Also, you are assuming low order byte first which may not be portable.
On 04/09/2019 11:14, LacaK wrote:
Nice! Thank you very much.
As an alternative for F:TextFile I am using:
procedure UCS2ReadLn(var F: TextFile; out s: String);
var
Nice! Thank you very much.
As an alternative for F:TextFile I am using:
procedure UCS2ReadLn(var F: TextFile; out s: String);
var
c: record
case boolean of
false: (a: array[0..1] of AnsiChar);
true : (w: WideChar);
end;
begin
s:='';
while not Eof(F) do begin
Sy
is there any smart way how to read string data line by line from UCS2
encoded text files (lines delimited by $0A00).
So, some LoadFromFile with a stream is no option for you?
It should be an option, but AFAIK LoadFromFile with optional TEncoding
is not a part of FPC 3.0.4
It is only in up
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
On Wed, Sep 4, 2019 at 7:46 AM LacaK wrote:
> is there any smart way how to read string data line by line from UCS2
> encoded text files (lines delimited by $0A00).
So, some LoadFromFile with a stream is no option for you?
> I wonder if Delphi supports ReadLn() for UTF-16 encoded text files ...