Question

I was needing to change the encoding of a compressed .dmp file created using the pg_dump command. Currently I only have the dump file and not the whole database. How can I alter the file to be compliant with another encoding? I would like to go from win1252 to latin1. When using iconv on a linux machine, it tells me win1252 is not supported.

Was it helpful?

Solution

A .dmp file from Postgres is a regular plain text file so you should be able to use e.g. iconv. Say you wanted to switch from UTF-8 to LATIN1, you could do:

iconv -f utf-8 -t latin1 <infile >outfile

Please note though that this will only change the encoding of the characters. If you need to change the DDL that is used to create the tables, columns etc, you will need to modify the file manually. Or import it, make the changes and then export again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top