[postgis-devel] [PostGIS] #1303: [PATCH] shp2pgsql does not respect PGCLIENTENCODING

PostGIS trac at osgeo.org
Wed Nov 16 16:04:37 PST 2011


#1303: [PATCH] shp2pgsql does not respect PGCLIENTENCODING
-----------------------------------------+----------------------------------
 Reporter:  etourigny                    |       Owner:  mcayland     
     Type:  defect                       |      Status:  new          
 Priority:  medium                       |   Milestone:  PostGIS 1.5.4
Component:  loader/dumper                |     Version:  1.5.X        
 Keywords:  shp2pgsql, PGCLIENTENCODING  |  
-----------------------------------------+----------------------------------
 To avoid encoding problems, one has to use the -W encoding option to
 shp2pgsql.

 However, the PGCLIENTENCODING variable is designed to force all clients to
 use a different encoding and is easier to use than manually setting the
 encoding for all imports.

 It seems that shp2pgsql does not respect that variable.

 I have written a simple fix against 1.5.3 (tested in Ubuntu 11.04).

 {{{
 --- shp2pgsql-core.c~   2010-12-13 18:42:47.000000000 -0200
 +++ shp2pgsql-core.c    2011-11-16 21:34:20.000000000 -0200
 @@ -961,7 +961,11 @@
         config->forceint4 = 0;
         config->createindex = 0;
         config->readshape = 1;
 -       config->encoding = strdup(ENCODING_DEFAULT);
 +       /* config->encoding = strdup(ENCODING_DEFAULT); */
 +    if ( getenv("PGCLIENTENCODING") != NULL )
 +        config->encoding = strdup(getenv("PGCLIENTENCODING"));
 +    else
 +        config->encoding = strdup(ENCODING_DEFAULT);
         config->null_policy = POLICY_NULL_INSERT;
         config->sr_id = -1;
         config->hwgeom = 0;
 }}}

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/1303>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-devel mailing list