Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jHxJ4-0000Bb-3J for pgsql-general@arkaria.postgresql.org; Fri, 27 Mar 2020 22:18:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jHxJ2-0005H5-H8 for pgsql-general@arkaria.postgresql.org; Fri, 27 Mar 2020 22:18:24 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jHxJ1-0005Gw-QP for pgsql-general@lists.postgresql.org; Fri, 27 Mar 2020 22:18:24 +0000 Received: from campbell-lange.net ([178.79.140.51]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jHxIz-0001uj-Eq for pgsql-general@lists.postgresql.org; Fri, 27 Mar 2020 22:18:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=campbell-lange.net; s=it; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=mJPcGva0mugVq/E4wKMI3DzIsZCVb4m8J2v+A4oN0V0=; b=gEzXgOubdgLmCqWL4lkemi/kO 8TLxUIJb6AFm+mfCC7qHHfAre0CkAG85Yg0KibXy/3Oav0eq+uc9nEZ6EMtXVaLuEMJKGf0eX8GZA sto0UOYafKYO746FpaFn0qigrDIAn6kBZDyasQDyOjupJaOsKXz8mpcHJg0bro4SQfufs=; Received: from 186.164.198.146.dyn.plus.net ([146.198.164.186] helo=rory-t450s) by campbell-lange.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jHxIm-0006jZ-Js; Fri, 27 Mar 2020 22:18:08 +0000 Received: from rory by rory-t450s with local (Exim 4.92) (envelope-from ) id 1jHxJD-0007E1-Ck; Fri, 27 Mar 2020 22:18:35 +0000 Date: Fri, 27 Mar 2020 22:18:35 +0000 From: Rory Campbell-Lange To: Andrew Gierth Cc: Thomas Munro , Tom Lane , Matthias Apitz , "pgsql-generallists.postgresql.org" Subject: Re: \COPY to accept non UTF-8 chars in CHAR columns Message-ID: <20200327221835.GA27613@campbell-lange.net> References: <20200327153623.GA32266@sh4-5.1blu.de> <8922.1585323994@sss.pgh.pa.us> <87k135a2hd.fsf@news-spur.riddles.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87k135a2hd.fsf@news-spur.riddles.org.uk> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 27/03/20, Andrew Gierth (andrew@tao11.riddles.org.uk) wrote: > >>>>> "Thomas" == Thomas Munro 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' outfile Or: iconv -f WINDOWS-1252 -t UTF-8 -c < tempfile2 > tempfile3