Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r7cwV-0062IK-3m for pgsql-bugs@arkaria.postgresql.org; Mon, 27 Nov 2023 14:50:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1r7cvV-00EE9N-KH for pgsql-bugs@arkaria.postgresql.org; Mon, 27 Nov 2023 14:49:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r7cvV-00EE9F-Bx for pgsql-bugs@lists.postgresql.org; Mon, 27 Nov 2023 14:49:33 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r7cvS-008o8O-Sl for pgsql-bugs@lists.postgresql.org; Mon, 27 Nov 2023 14:49:32 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 3AREnT9P3852220; Mon, 27 Nov 2023 09:49:29 -0500 From: Tom Lane To: Rick Parrish cc: bugs Subject: Re: psql include text file with bom In-reply-to: <81ca2b25-6b3a-499a-9a09-2dd21253c2cb@unitrunker.net> References: <81ca2b25-6b3a-499a-9a09-2dd21253c2cb@unitrunker.net> Comments: In-reply-to Rick Parrish message dated "Sat, 25 Nov 2023 23:46:37 -0600" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3852218.1701096569.1@sss.pgh.pa.us> Date: Mon, 27 Nov 2023 09:49:29 -0500 Message-ID: <3852219.1701096569@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Rick Parrish 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