Re: Weird encoding behavior

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Leonardo M(dot) Ramé <martinrame(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Weird encoding behavior
Date: 2009-03-26 13:55:53
Message-ID: 20090326135553.GC11993@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Leonardo M. Ramé" wrote:
> Hi, I'm experiencing a weird behavior when storing latin characters to a
> PostgreSQL 8.3.1.876 server. The database is Latin1 encoded, and it is
> working since September 2008, it wasn't updated nor replaced since its
> first installation.
>
> The weirdness of the problem is that sometimes the characters are stored
> correctly, but sometimes doesn't (allways by the same program), the
> field type is Varchar(30), and for example the text "NUÑEZ" is stored as
> "NU?EZ".

You need to be sure that the client_encoding variable is set to whatever
the client is actually using. Some client programs may be using UTF8,
and thus they should do "SET client_encoding TO utf8" on connection
start; others may be using Win-1252, Latin1, or other encodings. If you
declare each correctly when the connection is established, the server
will do the right conversion for you automatically. If you fail to do
that you will have a mess of characters, just like you do now.

BTW it is very advisable to update to 8.3.7. It has a lot of bug fixes
since 8.3.1.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Marc Mamin 2009-03-26 14:57:12 ltree and full text search questions
Previous Message Grzegorz Jaśkiewicz 2009-03-26 13:19:21 Re: idle connection timeout