I have a database and exporting with pgsql2shp various shapefiles. But when I open the dbf the characters are displayed wrong. Example: BroeksterwÔld and this should be Broeksterwäld.

This probably has to do with encoding. The database is UTF-8. I tried to export the shapefiles as LATIN1, but I can't figure out how to do so.


I solved this problem by adding 'set pgclientencoding=latin1' (without quotes) to the batch script.

  • Stefan's answer is correct. In a Unix / bash environment, it must be export PGCLIENTENCODING=LATIN1. Uppercase is mandatory, at least in my environment (Mac OS X 10.10.1 and PostgreSQL 9.3). Commented Dec 23, 2014 at 20:03
  • This should have been a comment against the other answer, not a new answer.
    – BradHards
    Commented Dec 23, 2014 at 20:07

3 Answers 3


I solved this problem by adding 'set pgclientencoding=latin1' (without quotes) to the batch script.


There's the option -W for pgsql2shp that allows you to specify the encoding. You could also look into setting the PGCLIENTENCODING environment variable. Most data sets from either the Dutch CBS or the Dutch Kadaster come in the CP1252 encoding, not Latin1.

  • 1
    Thanks! I believe the -W option only works from shp 2 postgres and unfortunately not from postgres 2 shp. I tried to set the PGCLIENTENCODING environment variable, but I am not sure if I do it correctly. What do I need to set, would that by system variables and then under variable 'PGCLIENTENCODING' (without quotes) and under value 'Latin1' or 'CP1252' (without quotes). And how do I write the pgsql2shp command then. Like this: pgsql2shp.exe -f folder -h .. -p .. -u ... -P .. -g geometrie .., or do I need to add something. Thanks for your help!
    – Stefan
    Commented Aug 13, 2012 at 7:14

Which s/w are you using to view the shapefile?. If you use QGIS, it will allow you to select the encoding of the shapefile, and you can then save it with the new encoding. See also here

  • Thanks for the answer. But I would like to put the encoding in a script I have. Because there are 60 shapefile exports every month. I don't want to manually change the encoding every month for every file. Do you perhaps know a way to put it in a script.
    – Stefan
    Commented Aug 9, 2012 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.