Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id AEE339F9E66 for ; Thu, 30 Aug 2007 05:59:18 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 40300-01 for ; Thu, 30 Aug 2007 05:59:11 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from smtp-vbr16.xs4all.nl (smtp-vbr16.xs4all.nl [194.109.24.36]) by postgresql.org (Postfix) with ESMTP id 81C6F9F9A57 for ; Thu, 30 Aug 2007 05:59:14 -0300 (ADT) Received: from webmail.xs4all.nl (dovemail1.xs4all.nl [194.109.26.3]) by smtp-vbr16.xs4all.nl (8.13.8/8.13.8) with ESMTP id l7U8vBMK074976; Thu, 30 Aug 2007 10:57:11 +0200 (CEST) (envelope-from jtv@xs4all.nl) Received: from 125.24.219.40 (SquirrelMail authenticated user jtv) by webmail.xs4all.nl with HTTP; Thu, 30 Aug 2007 15:57:11 +0700 (ICT) Message-ID: <13676.125.24.219.40.1188464231.squirrel@webmail.xs4all.nl> In-Reply-To: References: Date: Thu, 30 Aug 2007 15:57:11 +0700 (ICT) Subject: Re: Problem with character encodings. From: "Jeroen T. Vermeulen" To: "Korumilli, Bala S (GE Healthcare)" Cc: pgsql-interfaces@postgresql.org User-Agent: SquirrelMail/1.4.8 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by XS4ALL Virus Scanner X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/25 X-Sequence-Number: 6619 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