I'm exporting my postgresql db using the command

su - postgres -c "pg_dump --inserts --column-inserts mydb" > export.sql

But when I open the exported file with vi, the letter with accents are not being displayed correctly, however the web app that reads data from this DB does show them ok.

Any hints ? Thanks.


It can either be due to

  • Your vi is not configured to support UTF-8 characters, try to add set fileencodings=utf-8,latin1 to your vimrc
  • Your pg_dump is not dumping as UTF-8, you can force it to do so by adding -E UTF8 to your pg_dump options
  • Thanks for your reply. I did both: 1) created a .vimrc under /root with the fileecodings entry and 2) added the --encoding=UTF8 option and exported but no luck. Any other hints? – xain Jan 20 '11 at 11:28
  • If you did both it should be okay, it's still showing weird characters? If so have you tried restoring the DB just to check? – lynxman Jan 20 '11 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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