Re: Character Encoding Question (Solved)

From: Don Parris <parrisdc(at)gmail(dot)com>
To: psycopg(at)postgresql(dot)org
Subject: Re: Character Encoding Question (Solved)
Date: 2013-03-29 02:18:58
Message-ID: CAJ-7yo=f7P6zEgieehEQNBR6kCztKuc_h+mGG=_f8_MReoO-9w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On Thu, Mar 28, 2013 at 9:21 PM, Joe Abbate <jma(at)freedomcircle(dot)com> wrote:

> On 28/03/13 16:59, Don Parris wrote:
> > If I created the database using the UTF-8 encoding, then why would some
> > data be encoded differently than the rest? And how can I control how
> > the data gets inserted? See my previous post, where I mentioned loading
> > a good chunk of the data via the \copy command in psql, and then later
> > added more via PGAdmin. Many records seem to work just fine, but quite
> > a few others don't - and I was just naively entering or loading data
> > without knowing any encoding was being changed.
>
> If the database is created with UTF-8 encoding, all character data will
> be encoded as UTF-8. The problem was that your client was using
> SQL_ASCII encoding so any UTF-8, non-ASCII data (i.e., characters above
> decimal 127) received from PG couldn't be decoded. IIRC the client
> encoding is set according to the template0 encoding. I would do a psql
> -l to see the encoding of other databases in your cluster, in particular
> template0, template1 and postgres.
>
> Joe
>

As per my previous post, I had difficulty trying to change the character
encoding, even though I logged in as superuser. So I dropped the test DB
and re-created it, re-installed my ltree extension and then finished
re-creating the tables and re-loading the data via \copy.

Finally, I ran my Python3 script against the data without setting the
client encoding and all works as expected. The upshot is I have a slightly
better understanding of the problem. I greatly appreciate everyone helping
out!

Regards,
Don
--
D.C. Parris, FMP, Linux+, ESL Certificate
Minister, Security/FM Coordinator, Free Software Advocate
http://dcparris.net/
<https://www.xing.com/profile/Don_Parris><http://www.linkedin.com/in/dcparris>
GPG Key ID: F5E179BE

Browse psycopg by date

  From Date Subject
Next Message Joe Abbate 2013-03-29 02:42:26 Re: Character Encoding Question
Previous Message Don Parris 2013-03-29 02:07:19 Re: Character Encoding Question