Re: invalid byte sequence ? - Mailing list pgsql-general

From Bruce Momjian
Subject Re: invalid byte sequence ?
Date
Msg-id 200608232247.k7NMls528659@momjian.us
Whole thread Raw
In response to Re: invalid byte sequence ?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Is this a TODO?

---------------------------------------------------------------------------

Tom Lane wrote:
> Andreas <maps.on@gmx.net> writes:
> > I've got pg 8.1.4 from the binary Windows installer.
> > Windows 2000 / German
> > Now I entered "\d" into psql on the text-console and got this:
> >
> > db_test=# \d
> > ERROR:  invalid byte sequence for encoding "UTF8": 0xfc6d6572220a
>
> I can replicate this by using a UTF8 database and running the client
> in a non-UTF8 locale.  For example
>
> $ LANG=de_DE.iso88591 psql postgres
> Dies ist psql 8.2devel, das interaktive PostgreSQL-Terminal.
>
> Geben Sie ein:  \copyright f�r Urheberrechtsinformationen
>                 \h f�r Hilfe �ber SQL-Anweisungen
>                 \? f�r Hilfe �ber interne Anweisungen
>                 \g oder Semikolon, um eine Anfrage auszuf�hren
>                 \q um zu beenden
>
> postgres=# \l
> ERROR:  invalid byte sequence for encoding "UTF8": 0xfc6d6572222c
> TIP:  This error can also happen if the byte sequence does not match the encoding expected by the server, which is
controlledby "client_encoding". 
> postgres=# \d
> ERROR:  invalid byte sequence for encoding "UTF8": 0xfc6d6572220a
> TIP:  This error can also happen if the byte sequence does not match the encoding expected by the server, which is
controlledby "client_encoding". 
> postgres=# \encoding
> UTF8
> postgres=#
>
> The problem here is that psql is using gettext() to convert column
> headings for its display to German, and gettext() sees its locale
> as specifying ISO8859-1, so that's the encoding it produces.  When
> that data is sent over to the server --- which thinks that the
> client is using UTF8 encoding, because it hasn't been told any
> different --- the server quite naturally barfs.
>
> We've known about this and related issues with gettext for some time,
> but a bulletproof solution isn't clear.  For the moment all you can
> do is be real careful about making your locale settings match up.
>
>             regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
>                http://archives.postgresql.org

--
  Bruce Momjian   bruce@momjian.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: invalid byte sequence ?
Next
From: Tom Lane
Date:
Subject: Re: invalid byte sequence ?