Re: \COPY to accept non UTF-8 chars in CHAR columns

From: Rory Campbell-Lange <rory(at)campbell-lange(dot)net>
To: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
Cc: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Matthias Apitz <guru(at)unixarea(dot)de>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: \COPY to accept non UTF-8 chars in CHAR columns
Date: 2020-03-27 22:18:35
Message-ID: 20200327221835.GA27613@campbell-lange.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 27/03/20, Andrew Gierth (andrew(at)tao11(dot)riddles(dot)org(dot)uk) wrote:
> >>>>> "Thomas" == Thomas Munro <thomas(dot)munro(at)gmail(dot)com> writes:
>
> Thomas> Something like this approach might be useful for fixing the CSV file:
>
> Thomas> https://codereview.stackexchange.com/questions/185821/convert-a-mix-of-latin-1-and-utf-8-to-proper-utf-8
>
> Or:
>
> perl -MEncode -pe '
> use bytes;
> sub c { decode("UTF-8",shift,sub { decode("windows-1252", chr(shift)) }); }
> s/([\x80-\xFF]+)/encode("UTF-8",c($1))/eg' <infile >outfile

Or:

iconv -f WINDOWS-1252 -t UTF-8 -c < tempfile2 > tempfile3

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Gierth 2020-03-27 22:32:48 Re: \COPY to accept non UTF-8 chars in CHAR columns
Previous Message Justin King 2020-03-27 22:10:03 Re: PG12 autovac issues