Unix Technical Forum

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

This is a discussion on Inserting é in psql - invalid byte sequence for encoding "UNICODE": 0xe9 within the Pgsql General forums, part of the PostgreSQL category; --> I created a new database with encoding UTF8, connected using psql, and ensured the client encoding is also UTF8 ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-09-2008, 08:46 AM
CSN
 
Posts: n/a
Default Inserting é in psql - invalid byte sequence for encoding "UNICODE": 0xe9

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

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-09-2008, 08:46 AM
Martijn van Oosterhout
 
Posts: n/a
Default Re: Inserting =?iso-8859-1?Q?=E9?=

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.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFEF+CuIB7bNG8LQkwRAvkeAJ4nHJI6YgH3wYop7kMFZX cUPJxOmwCdFYG1
NDrG7X0eN09hHt/zETXYbVo=
=n/pT
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-09-2008, 08:46 AM
Richard Huxton
 
Posts: n/a
Default Re: Inserting =?ISO-8859-1?Q?=E9_in_psql_-_inv?=

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


---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-09-2008, 08:46 AM
Tom Lane
 
Posts: n/a
Default Re: Inserting in psql - invalid byte sequence for encoding "UNICODE": 0xe9

CSN <cool_screen_name90001@yahoo.com> 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

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:23 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com