[gdal-dev] ogr2ogr encoding

Frank Warmerdam warmerdam at pobox.com
Wed May 27 13:10:16 EDT 2009


Alexandre Dube wrote:
> Hi,
> 
>  I need to add a dbf file to a postgis database.  I use ogr2ogr with the 
> postgresql driver for that.  Problem is, I get an encoding error :
> 
> === ERROR START ===
> Warning 1: PQescapeString(): incomplete multibyte character
> 
>  input: 'Río'
>    got: 'Río '
> 
> ERROR 1: INSERT command for new feature failed.
> ERROR:  invalid byte sequence for encoding "UTF8": 0xed6f20
> HINT:  This error can also happen if the byte sequence does not match 
> the encoding expected by the server, which is controlled by 
> "client_encoding".
> === ERROR END ===
> 
>  I tried to set the database encoding of my database with \encoding or 
> SET CLIENT_ENCODING TO 'encoding'; but it's not working.  I tried latin1 
> and UTF8.  What am I missing ?

Alexandre,

The OGR Postgres driver help says:

"""
By default it is assumed that text being sent to Postgres is in the UTF-8
encoding.  This is fine for plain ASCII, but can result in errors for
extended characters (ASCII 155+, LATIN1, etc).  While OGR provides no direct
control over this, you can set the PGCLIENTENCODING environment variable
to indicate the format being provided.  For instance, if your text is
LATIN1 you could set the environment variable to LATIN1 before using OGR
and input would be assumed to be LATIN1 instead of UTF-8. <p>
"""

Could you try setting the PGCLIENTENCODING environment variable to LATIN1
before running ogr2ogr?

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the gdal-dev mailing list