Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q2A0k-0005BW-8o for pgsql-general@arkaria.postgresql.org; Thu, 25 May 2023 12:24:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q2A0i-0003Yu-M1 for pgsql-general@arkaria.postgresql.org; Thu, 25 May 2023 12:24:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q2A0i-0003Yk-BB for pgsql-general@lists.postgresql.org; Thu, 25 May 2023 12:24:04 +0000 Received: from mout-u-204.mailbox.org ([2001:67c:2050:101:465::204]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q2A0f-0024IQ-4Z for pgsql-general@lists.postgresql.org; Thu, 25 May 2023 12:24:03 +0000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4QRnKN5LrVz9sZZ; Thu, 25 May 2023 14:23:52 +0200 (CEST) Date: Thu, 25 May 2023 14:23:50 +0200 (CEST) From: Erik Wienhold To: "Peter J. Holzer" , pgsql-general@lists.postgresql.org Message-ID: <1398526026.221236.1685017430977@office.mailbox.org> In-Reply-To: <20230525112651.hehzirqm2qzpfxkr@hjp.at> References: <20230525112651.hehzirqm2qzpfxkr@hjp.at> Subject: Re: Maintaining accents with "COPY" ? MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Priority: 3 Importance: Normal List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 25/05/2023 13:26 CEST Peter J. Holzer wrote: > > On 2023-05-25 07:14:40 +0000, Laura Smith wrote: > > I'm currently doing a CSV export using COPY: > > > > COPY (select * from foo where bar=3D'foo') TO '/tmp/bar.csv' DELIMITER = ',' CSV HEADER; > > > > This works great apart from accents are not preserved in the output, > > for example =C3=A9 gets converted to random characters, e.g. =E2=88=9A= =C2=A9 or similar. > > How do you check the output? > > If a single character is turned into 2 or 3 characters the issue is > usually that the program which produces the output (in the case of COPY > I think that would be the PostgreSQL server, not the client) produces > UTF-8, but the program consuming it expects an 8-bit character set > (typically windows-1252). See if oyu can tell that program that the file > is in UTF-8. > > > How can I preserve accents ? > > They probably already are preserved. You're right. The bytes are probably interpreted as Mac OS Roman: =09$ echo =C3=A9 | iconv -f macintosh =09=E2=88=9A=C2=A9 =09$ echo -n =C3=A9 | xxd =0900000000: c3a9 -- Erik