[postgis-users] re: shp2sql and UTF8 question on Windows

Markus Schaber schabi at logix-tt.com
Wed Jan 25 01:01:53 PST 2006


Hi, Randy,

Randy George wrote:

> I have a database created with ENCODING = 'UTF8'
>
> psql:test.sql:15: ERROR:  invalid UTF-8 byte sequence detected near byte
> 0xa1
> 
> CONTEXT:  COPY county, line 1, column NAME: "Manatí"
> 
> ROLLBACK

We had a similar problem and solved it without the -W switch:

(echo 'set client_encoding TO LATIN9;' ; shp2psql blah blubb) | psql foo bar

Thus we shifted the encoding to the backend. This works with all
encodings that are ASCII-compatible and so retain the SQL commands.
(thus all ISO Latin encondings as well as UTF-8, but not UTF-16 or EBCDIC).

I don't know whether the pipe magic works under windows without cygwin,
but you may use the following trick: First, dump the SQL into a
temporary file:

shp2psql blah blubb > path\to\tempfile.sql

and then run psql to set the encoding and insert the dump:

geodb=# set client_encoding TO LATIN9;
SET
geodb=# \i path\to\tempfile.sql

Maybe we should add an "send client_encoding" command switch (that is
mutually exclusive with -W) to shp2pgsql. I'll have a look into this.

HTH,
Schabi

-- 
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf.     | Software Development GIS

Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org



More information about the postgis-users mailing list