Re: Problem with character encodings.

From: "Jeroen T(dot) Vermeulen" <jtv(at)xs4all(dot)nl>
To: "Korumilli, Bala S (GE Healthcare)" <Bala(dot)Korumilli(at)ge(dot)com>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Problem with character encodings.
Date: 2007-08-30 08:57:11
Message-ID: 13676.125.24.219.40.1188464231.squirrel@webmail.xs4all.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

On Wed, August 29, 2007 13:59, Korumilli, Bala S (GE Healthcare) wrote:

> If i use PGADMIN to run this query, '°' is properly inserted into
> database.
>
> But If i write a c++ program using LIBPQ to run this query, I get an error
> of invalid byte sequence like this..
>
> ERROR: invalid byte sequence for encoding "UTF8".
>
> I also observed the same error comes for all the characters other than
> ascii(0-127).
> Is it a limitation of LibPQ library?

No. Inserting and extracting characters like this should be no problem,
*if* they are properly encoded.

> The follwing information may be helpful to you.
> DataBase encoding: UTF8.
> client_encoding: UTF8
> Postgres version: 8.2.3

The database doesn't expose its encoding IIRC, only its character set. So
it's possible that that should be Unicode, not UTF-8.

But how did you specify this special character in your C++ source file?
Because if you typed it in directly as a non-ASCII character, it's quite
possible that your editor and your compiler disagree on encoding. Or that
the compiler uses an encoding that does not happen to match the client
encoding.

Jeroen

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Jeroen T. Vermeulen 2007-08-30 15:39:25 Re: Problem with character encodings.
Previous Message Tom Lane 2007-08-30 00:19:23 Re: plpgsql: defuault parameters and constant function parameters