public inbox for [email protected]  
help / color / mirror / Atom feed
From: Jean-Christophe BOGGIO <[email protected]>
To: [email protected] <[email protected]>
Subject: Importing a Windows database (in en_GB.CP1252) to linux
Date: Mon, 1 Dec 2025 14:37:43 +0100
Message-ID: <[email protected]> (raw)

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



reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Importing a Windows database (in en_GB.CP1252) to linux
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox