[postgis-users] Tools to change the encoding of the SHP/DBF files (from Latin1 to UTF-8)

485 views
Skip to first unread message

Mac Wind

unread,
May 8, 2012, 8:56:28 AM5/8/12
to postgi...@postgis.refractions.net
Hi.

Using PostGIS 1.5 on Windows, I get this error message when trying to import a SHP:
----------------
Unable to convert data value to UTF-8 (iconv reports "Invalid argument"). Current encoding is "UTF-8". Try "LATIN1" (Western European), or one of the values described at http://www.postgresql.org/docs/current/static/multibyte.html.
----------------

Really my data are in Latin1 encoding, but I don't want to change the encoding of the DataBase into Latin1, but change the encoding of the SHP (in fact, of the DBF) into UTF-8.

Which tool could I use to do this? Thank you very much.

Sandro Santilli

unread,
May 8, 2012, 9:13:26 AM5/8/12
to PostGIS Users Discussion
You don't have to change DB encoding, just tell the loader that your
data is in Latin1:

$ shp2pgsql -W Latin1 ...

--strk;

,------o-.
| __/ | Delivering high quality PostGIS 2.0 !
| / 2.0 | http://strk.keybit.net - http://vizzuality.com
`-o------'

_______________________________________________
postgis-users mailing list
postgi...@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

Mac Wind

unread,
May 10, 2012, 5:39:28 PM5/10/12
to PostGIS Users Discussion
Hi Sandro. Thank you very much for your answer.

With that parameter (-W), am I changing the encoding of the DB or I am merely indicating the encoding of the source?

Regards.

Lee Hachadoorian

unread,
May 10, 2012, 5:58:05 PM5/10/12
to PostGIS Users Discussion
On Thu, May 10, 2012 at 5:39 PM, Mac Wind <macw...@gmail.com> wrote:
> Hi Sandro. Thank you very much for your answer.
>
> With that parameter (-W), am I changing the encoding of the DB or I am
> merely indicating the encoding of the source?
>
> Regards.

The latter. I don't think it's possible to change the server encoding
once the database is created. This switch has the same effect as

SET client_encoding = 'LATIN1';

--Lee
Reply all
Reply to author
Forward
0 new messages