Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vQ46L-008KHF-2A for pgsql-admin@arkaria.postgresql.org; Mon, 01 Dec 2025 13:38:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vQ46I-002o8z-1k for pgsql-admin@arkaria.postgresql.org; Mon, 01 Dec 2025 13:37:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with utf8esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vQ46I-002o8p-0L for pgsql-admin@lists.postgresql.org; Mon, 01 Dec 2025 13:37:58 +0000 Received: from facteur.thefreecat.org ([2a01:4f8:222:794::2]) by makus.postgresql.org with utf8esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vQ46F-002Zyj-0O for pgsql-admin@lists.postgresql.org; Mon, 01 Dec 2025 13:37:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thefreecat.org; s=thefreecat; t=1764596264; bh=HVxduJtxPdVhdM0wpW0q0SSBER0m+EYWlZLWLJ1qVdw=; h=Date:To:From:Subject; b=DUIBeSg3b23rIjGjiJ9FhxuaLl/2yITNILb2octm3KTXrdaAxNiOYrlRzFC/xk7iz 410EpkVErsdJTFMgljuGxVOBfnhtOIYt6x2jJfGme6RluO8roRJIIyURLNkwSAvIPw xjPak2MN5id92O2+cVRoLhfBIlgwGd2tPugIj0bisDZ9npk21HkIMYPMXgZXC Original-Subject: Importing a Windows database (in en_GB.CP1252) to linux Original-From: Jean-Christophe BOGGIO Received: from [192.168.1.25] (lmontsouris-656-1-93-81.w82-127.abo.wanadoo.fr [::ffff:82.127.255.81]) (AUTH: LOGIN cat, TLS: TLS1.3,128bits,ECDHE_RSA_AES_128_GCM_SHA256) by facteur.thefreecat.org with ESMTPSA id 000000000DA25CCA.00000000692D9A28.001106C1; Mon, 01 Dec 2025 14:37:44 +0100 Content-Type: multipart/alternative; boundary="------------0nfDYg3BWPwQUBCxUcZIUJFJ" Message-ID: <5d7b5d51-a7c7-4cf2-943c-49b93441b8fa@thefreecat.org> Date: Mon, 1 Dec 2025 14:37:43 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US, fr To: "pgsql-admin@lists.postgresql.org" From: Jean-Christophe BOGGIO Subject: Importing a Windows database (in en_GB.CP1252) to linux List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------0nfDYg3BWPwQUBCxUcZIUJFJ Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hello, I have a (*custom*) backup created on a Windows machine in en_GB.CP1252 encoding. And of course, some characters can't be imported because they don't exist in UTF-8. So I created a new cluster on PG18 port 5433 initialized in WIN1252 encoding: $ \l imlocal                                            List of databases  Name   | Owner | Encoding | Locale Provider | Collate | Ctype | Locale | ICU Rules | Access privileges ---------+-------+----------+-----------------+---------+-------+--------+-----------+------------------- imlocal | cat   | WIN1252  | libc            | C       | C     | ∅    | ∅       | ∅ (1 row) I am now trying to import the data in that database but I keep getting this error: $ pg_restore -p 5433 -t csakafl -d imlocal imlocal20251127.backup pg_restore: error: COPY failed for table "csakafl": ERROR:  invalid byte sequence for encoding "UTF8": 0x92 CONTEXT:  COPY csakafl, line 298 So pg_restore still thinks I want to use UTF8. So I created an en_GB.CP1252 locales definitions folder like this: mkdir ~/locales cd ~/locales cp cp /usr/share/i18n/charmaps/CP1252.gz . gunzip CP1252.gz localedef -cv -i en_GB -f CP1252 ./en_GB.CP1252 Then I now want to use this to restore my database so I tried setting: setenv LOCPATH ~/locales setenv LC_ALL en_GB.CP1252 setenv LANG en_GB.CP1252 And even forcing LC_ALL when launching pg_restore: $ LC_ALL=en_GB.CP1252 pg_restore -p 5433 -t csakafl -d imlocal imlocal20251127.backup pg_restore: error: COPY failed for table "csakafl": ERROR:  invalid byte sequence for encoding "UTF8": 0x92 CONTEXT:  COPY csakafl, line 298 What am I doing wrong? Thanks for your help, JC --------------0nfDYg3BWPwQUBCxUcZIUJFJ Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hello,

I have a (custom) backup created on a Windows machine in en_GB.CP1252 encoding. And of course, some characters can't be imported because they don't exist in UTF-8.

So I created a new cluster on PG18 port 5433 initialized in WIN1252 encoding:

$ \l imlocal
                                           List of databases
 Name   | Owner | Encoding | Locale Provider | Collate | Ctype | Locale | ICU Rules | Access privileges  
---------+-------+----------+-----------------+---------+-------+--------+-----------+-------------------
imlocal | cat   | WIN1252  | libc            | C       | C     | ∅    | ∅       | ∅
(1 row)

I am now trying to import the data in that database but I keep getting this error:

$ pg_restore -p 5433 -t csakafl -d imlocal imlocal20251127.backup
pg_restore: error: COPY failed for table "csakafl": ERROR:  invalid byte sequence for encoding "UTF8": 0x92
CONTEXT:  COPY csakafl, line 298

So pg_restore still thinks I want to use UTF8.

So I created an en_GB.CP1252 locales definitions folder like this:

mkdir ~/locales
cd ~/locales
cp cp /usr/share/i18n/charmaps/CP1252.gz .
gunzip CP1252.gz
localedef -cv -i en_GB -f CP1252 ./en_GB.CP1252

Then I now want to use this to restore my database so I tried setting:

setenv LOCPATH ~/locales
setenv LC_ALL en_GB.CP1252
setenv LANG en_GB.CP1252

And even forcing LC_ALL when launching pg_restore:

$ LC_ALL=en_GB.CP1252 pg_restore -p 5433 -t csakafl -d imlocal imlocal20251127.backup
pg_restore: error: COPY failed for table "csakafl": ERROR:  invalid byte sequence for encoding "UTF8": 0x92
CONTEXT:  COPY csakafl, line 298

What am I doing wrong?

Thanks for your help,

JC


--------------0nfDYg3BWPwQUBCxUcZIUJFJ--