Re: psql include text file with bom

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Rick Parrish <ai5jt(at)unitrunker(dot)net>
Cc: bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: psql include text file with bom
Date: 2023-11-27 14:49:29
Message-ID: 3852219.1701096569@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Rick Parrish <ai5jt(at)unitrunker(dot)net> writes:
> I think it would be reasonable for the include command to skip over any
> BOM found in the first two or three bytes of a file.

This has been proposed before, and rejected before. psql has no
inherent knowledge of what encoding an input file is in, and therefore
no justification to assume that a bit-pattern it sees there is a BOM.
In non-UTF8 encodings it could very easily be valid data.

(For that matter, it's also valid data in UTF8: it's the same bit
pattern as U+FEFF ZERO WIDTH NO-BREAK SPACE. Programs that emit
one into UTF8 streams, and expect it not to be taken as data,
are frankly broken.)

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Adrian Klaver 2023-11-27 16:12:12 Re: Could not read from file "pg_subtrans/00F5" at offset 122880: Success.
Previous Message Sri Mrudula Attili 2023-11-27 11:50:26 Re:Could not read from file "pg_subtrans/00F5" at offset 122880: Success.