Index: doc/postgis.xml
===================================================================
RCS file: /home/cvs/postgis/postgis/doc/postgis.xml,v
retrieving revision 1.200
diff -u -r1.200 postgis.xml
--- doc/postgis.xml	23 Jan 2006 00:13:34 -0000	1.200
+++ doc/postgis.xml	25 Jan 2006 13:47:44 -0000
@@ -1473,16 +1473,46 @@
 
             <listitem>
 		<para>
-Specify encoding of the input data (dbf file).
-When used, all attributes of the dbf are converted from the specified
-encoding to UTF8. The resulting SQL output will contain a <code>SET
-CLIENT_ENCODING to UTF8</code> command, so that the backend will be able
-to reconvert from UTF8 to whatever encoding the database is configured
-to use internally.
+		Specify encoding of the input data (dbf file).
+		When used, all attributes of the dbf are converted from the specified
+		encoding to UTF8. The resulting SQL output will contain a <code>SET
+		CLIENT_ENCODING to UTF8</code> command, so that the backend will be able
+		to reconvert from UTF8 to whatever encoding the database is configured
+		to use internally.
+		</para>
+		<para>
+		Cannot be combined with -e, and is only available when compiled with 
+		iconv support. 
+		If none of -W and -e are specified, the servers assumes its default
+		encoding, which depends on configuration and database creation options,
+		usually ASCII.
 		</para>
             </listitem>
           </varlistentry>
 
+          <varlistentry>
+            <term>-e &lt;encoding&gt;</term>
+
+            <listitem>
+		<para>
+		Sets the specified encoding as client_encoding in the produced SQL
+		dumps, but outputs the data unconverted. This option does not need the 
+		iconv library, but only works with ASCII-compatible single-byte encodings 
+		(such as LATIN-1 or UTF-8). Other encodings like UTF-16 or EBCDIC will 
+		break the parsing of SQL commands, as those are always written in ASCII. 
+		Also note that the server currently cannot convert freely between all 
+		endodings. E. g. you cannot insert LATIN-1 date into a LATIN-9 database 
+		this way, but it is possible to insert all known encodings into an UTF-8 
+		encoded database.
+		</para>
+		<para>
+		Cannot be combined with -W.
+		If none of -W and -e are specified, the servers assumes its default
+		encoding, which depends on configuration and database creation options,
+		usually ASCII.
+		</para>
+            </listitem>
+          </varlistentry>
         </variablelist>
 
         <para>Note that -a, -c, -d and -p are mutually exclusive.</para>
Index: doc/man/shp2pgsql.1
===================================================================
RCS file: /home/cvs/postgis/postgis/doc/man/shp2pgsql.1,v
retrieving revision 1.8
diff -u -r1.8 shp2pgsql.1
--- doc/man/shp2pgsql.1	24 Nov 2005 20:11:05 -0000	1.8
+++ doc/man/shp2pgsql.1	25 Jan 2006 13:47:44 -0000
@@ -59,8 +59,34 @@
 
 .TP 
 \fB\-W\fR <\fIencoding\fR>
-Specify the character \fIencoding\fR of Shapefile's attributes.
-If this option is used the output will be encoded in UTF-8.
+Specify \fIencoding\fR of the input data (dbf file).
+When used, all attributes of the dbf are converted from the specified
+encoding to UTF8. The resulting SQL output will contain a <code>SET
+CLIENT_ENCODING to UTF8</code> command, so that the backend will be able
+to reconvert from UTF8 to whatever encoding the database is configured
+to use internally.
+
+Cannot be combined with -e, and is only available when compiled with 
+iconv support. If none of -W and -e are specified, the servers assumes 
+its default encoding, which may depend on locale, server configuration 
+and database creation options, usually ASCII.
+
+.TP 
+\fB\-e\fR <\fIencoding\fR>
+
+Sets the specified \fIencoding\fR as client_encoding in the produced SQL
+dumps, but outputs the data unconverted. This option does not need the 
+iconv library, but only works with ASCII-compatible single-byte encodings 
+(such as LATIN-1 or UTF-8). Other encodings like UTF-16 or EBCDIC will 
+break the parsing of SQL commands, as those are always written in ASCII. 
+Also note that the server currently cannot convert freely between all 
+endodings. E. g. you cannot insert LATIN-1 date into a LATIN-9 database 
+this way, but it is possible to insert all known encodings into an UTF-8 
+encoded database.
+
+If none of -W and -e are specified, the servers assumes its default
+encoding, which depends on configuration and database creation options,
+usually ASCII.
 
 .TP 
 \fB\-I\fR
Index: loader/shp2pgsql.c
===================================================================
RCS file: /home/cvs/postgis/postgis/loader/shp2pgsql.c,v
retrieving revision 1.106
diff -u -r1.106 shp2pgsql.c
--- loader/shp2pgsql.c	16 Jan 2006 10:42:58 -0000	1.106
+++ loader/shp2pgsql.c	25 Jan 2006 13:47:45 -0000
@@ -82,6 +82,7 @@
 int	hwgeom = 0; /* old (hwgeom) mode */
 #ifdef USE_ICONV
 char	*encoding=NULL;
+char	s*client_encoding=NULL;
 #endif
 int null_policy = insert_null;
 
@@ -402,6 +403,10 @@
 	}
 #endif /* defined USE_ICONV */
 
+	if ( client_encoding )
+	{
+		printf("SET CLIENT_ENCODING TO %s;\n", client_encoding);
+	}
 	/*
 	 * Drop table if requested
 	 */
@@ -762,10 +767,16 @@
 	fprintf(stderr, "  -w  Use wkt format (for postgis-0.x support - drops M - drifts coordinates).\n");
 #ifdef USE_ICONV
 	fprintf(stderr, "\n");
+	fprintf(stderr, "  (-W|e) These are mutually exclusive options:\n");
 	fprintf(stderr, "  -W <encoding> Specify the character encoding of Shape's\n");
-	fprintf(stderr, "     attribute column. (default : \"ASCII\")\n");
+	fprintf(stderr, "     attribute columns. (default : \"ASCII\") The data will be\n");
+	fprintf(stderr, "     converted to UTF-8 and the client_encoding set appropriately.");
 #endif
 	fprintf(stderr, "\n");
+	fprintf(stderr, "  -e <encoding> Set the client_encoding sql option, and dumps the\n");
+	fprintf(stderr, "     data unconverted. Needs an ASCII-compatible encoding, and the\n");
+	fprintf(stderr, "     server does not support all encoding combinations.\n");
+	fprintf(stderr, "\n");
 	fprintf(stderr, "  -N <policy> Specify NULL geometries handling policy (insert,skip,abort)\n");
 	exit (exitcode);
 }
@@ -1282,6 +1293,9 @@
 		    fprintf(stderr, "WARNING: the -W switch will have no effect. UTF8 disabled at compile time\n");
 #endif
                     break;
+                case 'e':
+                    client_encoding = optarg;
+                    break;
 		case 'N':
 			switch (optarg[0])
 			{	
@@ -1305,6 +1319,11 @@
                }
 	}
 
+	if (client_encoding != NULL && encoding != NULL) {
+		fprintf(stderr, "Error: -e and -W cannot be combined!");
+		exit(1);
+	}
+
 	if ( !sr_id ) sr_id = "-1";
 
 	if ( !geom ) geom = "the_geom";
