Inserting é in psql - invalid byte sequence for encoding "UNICODE": 0xe9

Поиск
Список
Период
Сортировка
Искать

Inserting é in psql - invalid byte sequence for encoding "UNICODE": 0xe9

От:
CSN <cool_screen_name90001@yahoo.com>
Дата:
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

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).

CSN

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Inserting é

От:
Martijn van Oosterhout <kleptog@svana.org>
Дата:
Вложения:
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      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.

Re: Inserting é in psql - inv

От:
Richard Huxton <dev@archonet.com>
Дата:
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

Something isn't UTF-8, possibly your terminal settings?

If you have a text-editor that lets you set character-encoding then you 
can try feeding the query into psql from a file. If that works then it's 
your terminal.

I always have endless trouble with this sort of stuff myself, so you're 
not alone.
-- 
   Richard Huxton
   Archonet Ltd

Re: Inserting in psql - invalid byte sequence for encoding "UNICODE": 0xe9

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
CSN  writes:
> 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

Whatever you're typing in is not actually sending UTF8 to psql.
You probably need to be fooling with the settings of xterm or
whatever window system you're working in.

			regards, tom lane
FAQ