pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Erik Wienhold <ewie@ewie.name>
To: Peter J. Holzer <hjp-pgsql@hjp.at>
To: pgsql-general@lists.postgresql.org
Subject: Re: Maintaining accents with "COPY" ?
Date: Thu, 25 May 2023 14:23:50 +0200 (CEST)
Message-ID: <1398526026.221236.1685017430977@office.mailbox.org> (raw)
In-Reply-To: <20230525112651.hehzirqm2qzpfxkr@hjp.at>
References: <oecekDAbp5O7kdlV4eD_J2uPWFHDwuf4CO3DFaJHQiT7gbFp1peO0UYyAfkUDEvS1h8bjxrUMf91YPrjUr7Rib-flXJWwHyr2vRIt_S8hcI=@protonmail.ch>
	<20230525112651.hehzirqm2qzpfxkr@hjp.at>

> On 25/05/2023 13:26 CEST Peter J. Holzer <hjp-pgsql@hjp.at> 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='foo') TO '/tmp/bar.csv' DELIMITER ',' CSV HEADER;
> >
> > This works great apart from accents are not preserved in the output,
> > for example é gets converted to random characters, e.g. √© 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:

	$ echo é | iconv -f macintosh
	é
	$ echo -n é | xxd
	00000000: c3a9

--
Erik





view thread (6+ messages)  latest in thread

Message-ID: <1398526026.221236.1685017430977@office.mailbox.org>
Permalink:  ../1398526026.221236.1685017430977@office.mailbox.org/
Also on:    postgresql.org/message-id/1398526026.221236.1685017430977@office.mailbox.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: ewie@ewie.name, hjp-pgsql@hjp.at
  Subject: Re: Maintaining accents with "COPY" ?
  In-Reply-To: <1398526026.221236.1685017430977@office.mailbox.org>
  References: <oecekDAbp5O7kdlV4eD_J2uPWFHDwuf4CO3DFaJHQiT7gbFp1peO0UYyAfkUDEvS1h8bjxrUMf91YPrjUr7Rib-flXJWwHyr2vRIt_S8hcI=@protonmail.ch> <20230525112651.hehzirqm2qzpfxkr@hjp.at> <1398526026.221236.1685017430977@office.mailbox.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox