Re: Inserting é - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Inserting é
Date
Msg-id 20060315093854.GA6135@svana.org
Whole thread Raw
In response to Inserting é in psql - invalid byte sequence for encoding "UNICODE": 0xe9  (CSN <cool_screen_name90001@yahoo.com>)
List pgsql-general
On Wed, Mar 15, 2006 at 01:33:56AM -0800, CSN wrote:
> I created a new database with encoding UTF8, connected
> using psql, and ensured the client encoding is also
> UTF8 (Unicode). But when I try to insert characters
> like 'é', I get this error:
>
> ERROR:  invalid byte sequence for encoding "UNICODE":
> 0xe9

Well, the message is correct, that's not a valid unicode byte sequence.

> Isn't this possible with psql? Hopefully it's not
> necessary to insert with values like  '\xC3\xA1'
> instead (which I tried, but the values got inserted as
> is and weren't converted).

Well, if your client was a UTF-8 client, it would type those bytes when
you did a 'é'. However, since it looks like you're actually using
Latin-1 in your client, perhaps you should say:

set client_encoding=latin1;

(Personally I never understood why psql doesn't try to detect the
client encoding from the locale. Defaulting to the server encoding is
almost certainly wrong. Note psql, not libpq.)

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Attachment

pgsql-general by date:

Previous
From: CSN
Date:
Subject: Inserting é in psql - invalid byte sequence for encoding "UNICODE": 0xe9
Next
From: Richard Huxton
Date:
Subject: Re: pgsql and streams