*** pg_dump.c.orig 2005-06-28 20:49:10.000000000 +0100 --- pg_dump.c 2005-06-28 21:16:21.000000000 +0100 *************** *** 183,188 **** --- 183,189 ---- const char *pghost = NULL; const char *pgport = NULL; const char *username = NULL; + const char *dumpencoding = NULL; bool oids = false; TableInfo *tblinfo; int numTables; *************** *** 229,234 **** --- 230,236 ---- {"no-privileges", no_argument, NULL, 'x'}, {"no-acl", no_argument, NULL, 'x'}, {"compress", required_argument, NULL, 'Z'}, + {"encoding", required_argument, NULL, 'E'}, {"help", no_argument, NULL, '?'}, {"version", no_argument, NULL, 'V'}, *************** *** 277,283 **** } } ! while ((c = getopt_long(argc, argv, "abcCdDf:F:h:in:oOp:RsS:t:uU:vWxX:Z:", long_options, &optindex)) != -1) { switch (c) --- 279,285 ---- } } ! while ((c = getopt_long(argc, argv, "abcCdDE:f:F:h:in:oOp:RsS:t:uU:vWxX:Z:", long_options, &optindex)) != -1) { switch (c) *************** *** 309,314 **** --- 311,320 ---- attrNames = true; break; + case 'E': /* Dump encoding */ + dumpencoding = optarg; + break; + case 'f': filename = optarg; break; *************** *** 533,538 **** --- 539,553 ---- /* Set the datestyle to ISO to ensure the dump's portability */ do_sql_command(g_conn, "SET DATESTYLE = ISO"); + /* Set the client encoding */ + if (dumpencoding) + { + char *cmd = malloc(strlen(dumpencoding) + 32); + sprintf(cmd,"SET client_encoding='%s'", dumpencoding); + do_sql_command(g_conn, cmd); + free(cmd); + } + /* * If supported, set extra_float_digits so that we can dump float data * exactly (given correctly implemented float I/O code, anyway) *************** *** 675,680 **** --- 690,696 ---- printf(_(" -C, --create include commands to create database in dump\n")); printf(_(" -d, --inserts dump data as INSERT, rather than COPY, commands\n")); printf(_(" -D, --column-inserts dump data as INSERT commands with column names\n")); + printf(_(" -E, --encoding=ENCODING dump the data in encoding ENCODING\n")); printf(_(" -n, --schema=SCHEMA dump the named schema only\n")); printf(_(" -o, --oids include OIDs in dump\n")); printf(_(" -O, --no-owner skip restoration of object ownership\n"