It's an unsophisticated hack cobbled together to give you an idea (not the sort of thing you want in production code) but you can do something like the following; creating a descendant of TIniFile (or better of TCustomIniFile) to get you over one or two problematic .inis which have BOMs. This assumes the file is utf8 encoded:
unit noBOMIniFile;
{$mode objfpc}{$H+}
interface
uses IniFiles, FileUtil;
type
{ TNoBOMIniFile }
TNoBOMIniFile=class(TIniFile)
constructor Create(const AFileName: string; AEscapeLineFeeds: Boolean=False); override;
end;
implementation
{ TNoBOMIniFile }
constructor TNoBOMIniFile.Create(const AFileName: string;
AEscapeLineFeeds: Boolean);
var
tex, tex2: TextFile;
s, fn: string;
begin
if FileExistsUTF8(AFileName) then begin
AssignFile(tex, AFileName);
try
Reset(tex);
readln(tex, s);
if (s[1]=#$EF) and (s[2]=#$BB) and (s[3]=#$BF) then // probably a utf8 BOM
begin
fn:=AFileName+'noBOM.ini';
AssignFile(tex2, fn);
try
Rewrite(tex2);
WriteLn(tex2, copy(s, 4, Length(s)-3));
while not EOF(tex) do begin
readln(tex, s);
writeln(tex2, s);
end;
finally
CloseFile(tex2);
end;
end
else fn:=AFileName;
finally
CloseFile(tex);
end;
end;
inherited Create(fn, AEscapeLineFeeds);
end;
end.