We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent be5322c commit 27e26a6Copy full SHA for 27e26a6
1 file changed
source/apphelpers.pas
@@ -1340,6 +1340,9 @@ procedure OpenTextFile(const Filename: String; out Stream: TFileStream; var Enco
1340
Stream := TFileStream.Create(Filename, fmOpenRead or fmShareDenyNone);
1341
if Encoding = nil then
1342
Encoding := DetectEncoding(Stream);
1343
+ // For a 0-bytes file, override the encoding to one without BOM
1344
+ if _GetFileSize(Filename) < Length(Encoding.GetPreamble) then
1345
+ Encoding := UTF8NoBOMEncoding;
1346
// If the file contains a BOM, advance the stream's position
1347
BomLen := 0;
1348
if Length(Encoding.GetPreamble) > 0 then begin
0 commit comments