By default, Lazarus is not prepared to work with UTF8, functionality must be activated ... Even there are many functions to this day, fail with UTF8 strings.
Excuse me?
The entire LCL (and therefore Lazarus itself) is UTF8 based.
For instance TMemo, TSynEdit support filenames in UTF8 encoding and can load files with UTF8 BOM.
If I use an operating system that uses an UTF8 code page, (spanish / russian, etc.) I will have many problems that have not experienced those using standard code page.
Most Linux distro's default to UTF8, and Lazarus has no problem whatsoever with that.
One example is: read txt files that have been created or edited with M$ Notepad, M$ Notepad saves it as UTF8 With boom without asking (it occurs on an system with non standard code page).
See my comment above.
TStringList will also load such a file without any problem.
(Tested on W7, with Lazarus trunk, fpc 2.6.4, and yes I verified the BOM is actually there.)
So, with regard to this particular problem, your comments make no sense,
Note that UTF8 (as far as Pascal is concerned) is just a special case of ansistring (it's just not single-byte).For this problem it also does not matter wether you use Length or Utf8Length, since we are searching for a LineEnding, which will always be a single-byte.
IMO the encoding of the file (ANSI vs UTF8) is not relevant to this particular problem.
Bart