Обсуждение: problems with encoding and accent letters
My DB is UTF8 and I cannot change it. When I try to insert accent letters like è ò ... I get Query failed: ERROR: invalid byte sequence for encoding "UTF8": 0xe82729 HINT: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding" How Can I insert into fields of tables accents?
On 1 July 2010 15:43, aaaawwww <aaaawwww@libero.it> wrote: > My DB is UTF8 and I cannot change it. > When I try to insert accent letters like è ò ... I get > Query failed: ERROR: invalid byte sequence for encoding "UTF8": > 0xe82729 HINT: This error can also happen if the byte sequence does > not match the encoding expected by the server, which is controlled by > "client_encoding" > > How Can I insert into fields of tables accents? Clearly, whatever client you're using isn't based on UTF-8. It would have helped if you gave some background information, but you may find it useful to SET client_encoding TO whatever the client encoding of your client appliation is (I'd haza http://www.postgresql.org/docs/8.3/static/multibyte.html -- Regards, Peter Geoghegan
On 1 July 2010 15:43, aaaawwww <aaaawwww@libero.it> wrote: > My DB is UTF8 and I cannot change it. > When I try to insert accent letters like è ò ... I get > Query failed: ERROR: invalid byte sequence for encoding "UTF8": > 0xe82729 HINT: This error can also happen if the byte sequence does > not match the encoding expected by the server, which is controlled by > "client_encoding" > > How Can I insert into fields of tables accents? Whoops, hit return too early. Clearly, whatever client you're using isn't based on UTF-8. It would have helped if you gave some background information, but you may find it useful to SET client_encoding TO whatever the client encoding of your client appliation is (I'd hazard a guess that it's win1252 if you're in western Europe or North America. http://www.postgresql.org/docs/8.3/static/multibyte.html -- Regards, Peter Geoghegan
Sorry I forgot to say I am running an Italian php website with a
postgresql DB. Users can write messages eachothers.
This is my code:
$connessione_db = pg_connect("dbname=xxxxx user=yyyyy
password=zzzzzz");
$sql_insert_messaggio="insert into messaggio (text) values ('àèì');";
pg_exec ($connessione_db,$sql_insert_messaggio);
and I get that error. If I do not write messages with accents
everything works.
Is there a way to insert accents with any kind of encoding?
On 07/01/10 2:27 PM, aaaawwww wrote:
> Sorry I forgot to say I am running an Italian php website with a
> postgresql DB. Users can write messages eachothers.
> This is my code:
> $connessione_db = pg_connect("dbname=xxxxx user=yyyyy
> password=zzzzzz");
> $sql_insert_messaggio="insert into messaggio (text) values ('àèì');";
> pg_exec ($connessione_db,$sql_insert_messaggio);
>
> and I get that error. If I do not write messages with accents
> everything works.
>
> Is there a way to insert accents with any kind of encoding?
>
is your source code UTF-8 or is it ISO-8559-3 aka LATIN3 or something ?
you probably need to set your client_encoding according to the charset
used in the source SQL statements.
SET CLIENT_ENCODING='LATIN3';
when you do the inserts, the data will be converted from your
CLIENT_ENCODING to the proper database eencoding which is likely UTF8
per your error... and when you read it back, it will be converted back
to the current CLIENT_ENCODING
since this is a web app, do be sure your CLIENT_ENCODING matches the
mime type of your generated web pages...
On Jul 2, 12:39 am, pie...@hogranch.com (John R Pierce) wrote:
> On 07/01/10 2:27 PM, aaaawwww wrote:
>
> > Sorry I forgot to say I am running an Italian php website with a
> > postgresql DB. Users can write messages eachothers.
> > This is my code:
> > $connessione_db = pg_connect("dbname=xxxxx user=yyyyy
> > password=zzzzzz");
> > $sql_insert_messaggio="insert into messaggio (text) values ('àèì');";
> > pg_exec ($connessione_db,$sql_insert_messaggio);
>
> > and I get that error. If I do not write messages with accents
> > everything works.
>
> > Is there a way to insert accents with any kind of encoding?
>
> is your source code UTF-8 or is it ISO-8559-3 aka LATIN3 or something ?
>
> you probably need to set your client_encoding according to the charset
> used in the source SQL statements.
>
> SET CLIENT_ENCODING='LATIN3';
>
> when you do the inserts, the data will be converted from your
> CLIENT_ENCODING to the proper database eencoding which is likely UTF8
> per your error... and when you read it back, it will be converted back
> to the current CLIENT_ENCODING
>
> since this is a web app, do be sure your CLIENT_ENCODING matches the
> mime type of your generated web pages...
>
> --
> Sent via pgsql-general mailing list (pgsql-gene...@postgresql.org)
> To make changes to your subscription:http://www.postgresql.org/mailpref/pgsql-general
thank you. I did not change anything on my php scripts. I had <meta
http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> on
my web pages, so I converted it in <meta http-equiv="Content-Type"
content="text/html; charset=UTF-8"> and then everything worked!
Thank you again.