[gdal-dev] PGCLIENTENCODING in ogr2ogr (and QGIS)

Even Rouault even.rouault at spatialys.com
Fri Dec 3 06:04:02 PST 2021


Instead of turning Postgres client_encoding to LATIN1 (which won't work 
here because -f PostgreSQL goes through the CreateDataSource() OGR API, 
which will ignore destination dataset open options provided with -doo) , 
I would rather set the shapefile encoding with -oo 
ENCODING=ISO-8859-1,then the OGR shapefile reader will transcode 
internally from ISO-8859-1 to UTF-8, which should make Postgres API

Le 03/12/2021 à 14:55, matteo a écrit :
> Hi Rahkonen,
>
> sorry for the delay. The command, built with Processing in QGIS using 
> the GdalUtils utility is at the end:
>
> ogr2ogr -f PostgreSQL "PG:dbname='db' host=myhost port=myport 
> user='myuser' password='mypassword' sslmode=disable schemas=myschema" 
> shapefile.shp --config PG_USE_COPY YES -append -skipfailures -nlt 
> PROMOTE_TO_MULTI -doo PRELUDE_STATEMENTS="SET client_encoding TO LATIN1"
>
> a small file can be found here:
>
> https://faunalia.eu/~matteo/shapefile.zip
>
> and yes. The database encoding is:
>
> HOW SERVER_ENCODING;
>  server_encoding
> -----------------
>  UTF8
> (1 row)
>
> while the encoding of the shapefile is ISO-8859-1
>
> Thanks for any hint!
>
> Matteo
>
>
>
-- 
http://www.spatialys.com
My software is free, but my time generally not.



More information about the gdal-dev mailing list