Re: Inserting é

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: CSN <cool_screen_name90001(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Inserting é
Date: 2006-03-15 09:38:54
Message-ID: 20060315093854.GA6135@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)svana(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2006-03-15 09:42:31 Re: Inserting é in psql - inv
Previous Message Richard Huxton 2006-03-15 09:37:18 Re: out of memory using Postgres with Spring/Hibernate/Java