Re: \COPY to accept non UTF-8 chars in CHAR columns - Mailing list pgsql-general

From Rory Campbell-Lange
Subject Re: \COPY to accept non UTF-8 chars in CHAR columns
Date
Msg-id 20200327221835.GA27613@campbell-lange.net
Whole thread Raw
In response to Re: \COPY to accept non UTF-8 chars in CHAR columns  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Responses Re: \COPY to accept non UTF-8 chars in CHAR columns
List pgsql-general
On 27/03/20, Andrew Gierth (andrew@tao11.riddles.org.uk) wrote:
> >>>>> "Thomas" == Thomas Munro <thomas.munro@gmail.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



pgsql-general by date:

Previous
From: Justin King
Date:
Subject: Re: PG12 autovac issues
Next
From: Andrew Gierth
Date:
Subject: Re: \COPY to accept non UTF-8 chars in CHAR columns