Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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). – thomaskonrad Dec 23 '14 at 20:03
This should have been a comment against the other answer, not a new answer. – BradHards Dec 23 '14 at 20:07
up vote 4 down vote accepted

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

share|improve this answer

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.

share|improve this answer
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 Aug 13 '12 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

share|improve this answer
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 Aug 9 '12 at 14:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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