Re: problems with encoding and accent letters

From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: problems with encoding and accent letters
Date: 2010-07-01 22:39:06
Message-ID: 4C2D190A.9010408@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2010-07-01 23:01:11 Re: Is full-row updates slower than single-value updates
Previous Message Björn Lindqvist 2010-07-01 22:19:20 Re: Is full-row updates slower than single-value updates