From: | Erik Wienhold <ewie(at)ewie(dot)name> |
---|---|
To: | Laura Smith <n5d9xq3ti233xiyif2vp(at)protonmail(dot)ch>, postgre <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Maintaining accents with "COPY" ? |
Date: | 2023-05-25 07:48:26 |
Message-ID: | 1917340025.188822.1685000906999@office.mailbox.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> On 25/05/2023 09:14 CEST Laura Smith <n5d9xq3ti233xiyif2vp(at)protonmail(dot)ch> 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 can I preserve accents ?
Looks like an encoding issue and a mismatch between database encoding and client
encoding. You can check both with:
SHOW server_encoding;
SHOW client_encoding;
Then either set the client encoding or use COPY's encoding option to match the
database encoding (I assume utf8 in this example):
SET client_encoding = 'utf8';
COPY (...) TO /tmp/bar.csv DELIMITER ',' CSV HEADER ENCODING 'utf8';
--
Erik
From | Date | Subject | |
---|---|---|---|
Next Message | Laura Smith | 2023-05-25 10:08:58 | Re: Maintaining accents with "COPY" ? |
Previous Message | Laura Smith | 2023-05-25 07:14:40 | Maintaining accents with "COPY" ? |