Force option -g to shp2pgsql for compatibility with postgis < 2.0
Escape quote character in SQL replace function
Explicitely set client_encoding outside of copy function to support postgresql version < 9.1