Re: Weird encoding behavior - Mailing list pgsql-general

From Alvaro Herrera
Subject Re: Weird encoding behavior
Date
Msg-id 20090326135553.GC11993@alvh.no-ip.org
Whole thread Raw
In response to Weird encoding behavior  ("Leonardo M. Ramé" <martinrame@yahoo.com>)
List 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.

pgsql-general by date:

Previous
From: Grzegorz Jaśkiewicz
Date:
Subject: Re: idle connection timeout
Next
From: "Marc Mamin"
Date:
Subject: ltree and full text search questions