On Mon, Feb 7, 2022 at 9:54 PM James Richters via fpc-pascal <fpc-pascal@lists.freepascal.org> wrote:
> The part of my program that checks for the BOM is bigger than the actual CSV > read and write. Please let me know if the crash issue with no BOM gets fixed > so I can delete all this stuff that checks for it. That part can be a lot shorter: Open the file as a TFileStream Read the amount of bytes the UTF8-BOM has int an appropriate buffer. Check you really read that amount of bytes. Compare the buffer to the expected UTF8-BOM. This is a snippet from a function I have lying around: FS := TFileStreamUtf8.Create(Fn, fmOpenRead or fmShareDenyNone); try Len := FS.Read({%H-}Buf[0], BufLen); if (Len > 2) and (Buf[0]=$EF) and (Buf[1]=$BB) and (Buf[2]=$BF) then begin //UTF8 BOM -- Bart _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal