dimitri/pgloader — pull request #9 by dolfandringa (2012-03-27 16:37:11+00:00)
Title: Created a patch for pgloader to re-encode data into client_encoding

Since pgloader already reads the input data, and since python can handle more character encodings than postgres can, it makes sense for pgloader to re-encode all strings into the character encoding used for the client_encoding.
I created a patch that does this. If first checks if client_encoding was specified in the [pgsql] config section, if not, it checks for options.PG_CLIENT_ENCODING, and if that isn't present, it uses input_encoding.

For me, this worked when the input_encoding was mac_roman and the client_encoding was UTF8. When I didn't specify a client encoding, pgloader failed (as expected), since the input data contained characters which aren't possible to encode using latin9/charmap, which is the encoding in options.PG_CLIENT_ENCODING.