X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 16E23D7DD5 for ; Wed, 7 Sep 2005 02:03:52 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 97798-10 for ; Wed, 7 Sep 2005 05:03:49 +0000 (GMT) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.192]) by svr1.postgresql.org (Postfix) with ESMTP id BF21FD7D93 for ; Wed, 7 Sep 2005 02:03:49 -0300 (ADT) Received: by zproxy.gmail.com with SMTP id 8so877997nzo for ; Tue, 06 Sep 2005 22:03:49 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=IdCV0wu23ICSBA+HNvprls/h3tutbb4OOYJHQBNSlt6AgcFrMciNZFmFlnCVKShU876mYJ/yNskIUdV4V3y527HoT4DlB6n9zYWGqo04oIewfQYxlu+JqhVDRcJRUabfk7k3uyFMWParyJELJ+6qkcndkhJsG+jBR4fnqRb0Sc0= Received: by 10.36.148.16 with SMTP id v16mr6382098nzd; Tue, 06 Sep 2005 22:03:49 -0700 (PDT) Received: by 10.36.10.4 with HTTP; Tue, 6 Sep 2005 22:03:49 -0700 (PDT) Message-ID: Date: Wed, 7 Sep 2005 00:03:49 -0500 From: Miguel Higuera To: "Pradeepkumar, Pyatalo (IE10)" , pgsql-admin@postgresql.org Subject: Re: FW: Libpq - multibyte character support In-Reply-To: <77ED2BF75D59D1439F90412CC5B1097423F87B47@ie10-sahara.hiso.honeywell.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_31312_26046317.1126069429470" References: <77ED2BF75D59D1439F90412CC5B1097423F87B47@ie10-sahara.hiso.honeywell.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.436 required=5 tests=[AWL=0.384, HTML_60_70=0.027, HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] X-Spam-Level: X-Archive-Number: 200509/53 X-Sequence-Number: 18790 ------=_Part_31312_26046317.1126069429470 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline CREATE DATABASE name ENCODING =3D WIN1256 THIS MAY BE THE SOLUTION ALSO YOU CAN PROBE WITH : ALT, LATIN1 TO LATIN9, EUC_CN, EUC_JP,EUCCREATE DATABASE name ENCODING =3D= =20 WIN1256 THIS MAY BE THE SOLUTION ALSO YOU CAN PROBE WITH : ALT, LATIN1 TO LATIN9, EUC_CN, EUC_JP,EUC_KR...................... I WAIT THIS BE USEFULL _KR...................... I WAIT THIS BE USEFULL 2005/9/6, Pradeepkumar, Pyatalo (IE10) = : >=20 >=20 >=20 >=20 >=20 > Hi all,=20 > =20 > My question is does PgSQL libpq functions support multibyte=20 > characters...if not then is there a way to provide multibyte data t= o=20 > Postgres using libpq functions. The other question is does Postgres= support=20 > Chinese characters....if I insert chinese characters into a table, = when I=20 > read, will I get the same chinese characters. Please help me out in= this=20 > regard. > =20 > I have created a database with UNICODE support which has a=20 > table GSNames(Gsname varchar(40), status int, errorcode int)=20 > I tried to insert into this table from a simple C program=20 > using libpq functions....but it gives error as libpq does not suppo= rt wchar=20 > datatypes. Here is the code -=20 > =20 > int main()=20 > {=20 > // wchar_t szQuery[255];=20 > char szQuery[255];=20 > =20 > PGconn *DBCon;=20 > PGresult *DBResult;=20 > =20 > //Connect to the database with default settings=20 > DBCon =3D PQsetdbLogin(NULL, NULL, NULL, NULL, "test1",=20 > "postgres", ""); //test1 is database created with UNICODE encoding > =20 > //check if there is any error in connecting to the database=20 > if(PQstatus(DBCon) =3D=3D CONNECTION_BAD)=20 > {=20 > fprintf(stderr,"\nGetAttributeInfo(): Connection to database=20 > failed.");=20 > fprintf(stderr,"\nGetAttributeInfo(): %s",=20 > PQerrorMessage(DBCon));=20 > return ERROR_DB_CON;=20 > }=20 > else=20 > {=20 > fprintf(stderr,"\nGetAttributeInfo(): Connection to database=20 > successful.");=20 > }=20 > =20 > //form the DELETE command as character buffer.=20 > //swprintf(szQuery,500,L"INSERT INTO gsnames=20 > values('=D7=A2=B2=E1',2,2)");=20 > sprintf(szQuery,"INSERT INTO gsnames values('=D7=A2=B2=E1',2,2)");= =20 > =20 > //execute the command.=20 > DBResult =3D PQexec(DBCon, (char *)szQuery);=20 > =20 > //check for any errors in executing the query.=20 > if(PQresultStatus(DBResult) !=3D PGRES_COMMAND_OK)=20 > {=20 > fprintf(stderr,"\nGetAttributeInfo(): %s",=20 > PQresultErrorMessage(DBResult));=20 > PQclear(DBResult);=20 > PQfinish(DBCon);=20 > return ERROR_DB_EXEC;=20 > }=20 > else=20 > {=20 > fprintf(stderr,"\nDBInsertPointAttribute(): Insertion=20 > successful. No. of rows affected =3D %d.", PQntuples(DBResult)); > =20 > }=20 > =20 > PQclear(DBResult);=20 > PQfinish(DBCon);=20 > =20 > return 0;=20 > }=20 > =20 > The problem is I am not able to pass multibyte characters to=20 > postgres. Please help.....Thanks in advance.=20 > =20 > Between I am using Postgres version 7.4.3. While installing=20 > Pgsql, I dnt specify any encoding or multi byte character support f= or=20 > initdb. > =20 > Regs,=20 > Pradeep=20 > =20 > =20 > ------=_Part_31312_26046317.1126069429470 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline CREATE DATABASE name ENCODING =3D WIN1256

THIS MAY BE THE SOLUTION
ALSO YOU CAN PROBE WITH :
ALT, LATIN1 TO LATIN9, EUC_CN, EUC_JP,EUCCREATE DATABASE name ENCODING =3D = WIN1256

THIS MAY BE THE SOLUTION
ALSO YOU CAN PROBE WITH :
ALT, LATIN1 TO LATIN9, EUC_CN, EUC_JP,EUC_KR......................

I WAIT THIS BE USEFULL
_KR......................

I WAIT THIS BE USEFULL


2005/9/6, Pradeepkumar, Pyatalo (I= E10) <Pradeepkumar= .Pyatalo@honeywell.com>:



      Hi all,

      My question is does PgSQL libpq functions support multibyte characters...if not then is there a way to provide multibyte data to Postgres using libpq functions. The other question is does Postgres support Chinese characters....if I insert chinese characters into a table, when I read, will I get the same chinese characters. Please help me out in this regard.

      I have created = a database with UNICODE support which has a table GSNames(Gsname varchar(40= ), status int, errorcode int)
      I tried to insert into this table from a simple C program using libpq functions....but it gives error as libpq does not support wchar datatypes. Here is the code -

      int main()
      {
      //  =     wchar_t szQuery[255];
        &n= bsp;     char szQuery[255];

              PGconn *DBCon;
              PGresult *DBResult;

              //Connect to the database with default setting= s
              DBCon =3D PQsetdbLogin(NULL, NULL, NULL, NULL,= "test1", "postgres", ""); //test1 is databas= e created with UNICODE encoding

              //check if there is any error in connecting to= the database
              if(PQstatus(DBCon) =3D=3D CONNECTION_BAD)
              {
                  &nbs= p;   fpr= intf(stderr,"\nGetAttributeInfo(): Connection to database failed."= ;);
                  &nbs= p;   fpr= intf(stderr,"\nGetAttributeInfo(): %s", PQerrorMessage(DBCon));
                  &nbs= p;   ret= urn ERROR_DB_CON;
              }
              else
              {
                  &nbs= p;   fpr= intf(stderr,"\nGetAttributeInfo(): Connection to database successful.&= quot;);
              }
             =20
              //form the DELETE command as character buffer.=
              //swprintf(szQuery,500,L"INSERT INTO gsna= mes values('=D7=A2=B2=E1',2,2)");
              sprintf(szQuery,"INSERT INTO gsnames valu= es('=D7=A2=B2=E1',2,2)");

              //execute the command.
              DBResult =3D PQexec(DBCon, (char *)szQuery);

              //check for any errors in executing the query.=
              if(PQresultStatus(DBResult) !=3D PGRES_COMMAND= _OK)
              {
                  &nbs= p;   fpr= intf(stderr,"\nGetAttributeInfo(): %s", PQresultErrorMessage(DBRe= sult));
                  &nbs= p;   PQc= lear(DBResult);
                  &nbs= p;   PQf= inish(DBCon);
                  &nbs= p;   ret= urn ERROR_DB_EXEC;
              }
              else
              {
                  &nbs= p;   fpr= intf(stderr,"\nDBInsertPointAttribute(): Insertion successful. No. of = rows affected =3D %d.", PQntuples(DBResult));

              }

              PQclear(DBResult);
              PQfinish(DBCon);

              return 0;
      }

      The problem is = I am not able to pass multibyte characters to postgres. Please help.....Tha= nks in advance.

      Between I am using Postgres version 7.4.3. While installing Pgsql, I dnt specify any encoding or multi byte character support for initdb.


      Regs,
      Pradeep



------=_Part_31312_26046317.1126069429470--