pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
FW: Libpq - multibyte character support
3+ messages / 2 participants
[nested] [flat]

* FW: Libpq - multibyte character support
@ 2005-09-06 14:29 Pradeepkumar, Pyatalo (IE10) <Pradeepkumar.Pyatalo@honeywell.com>
  2005-09-07 05:03 ` Re: FW: Libpq - multibyte character support Miguel Higuera <miguelstratoss@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Pradeepkumar, Pyatalo (IE10) @ 2005-09-06 14:29 UTC (permalink / raw)
  To: pgsql-admin




> 	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];
> 	 	char szQuery[255];
> 
> 		PGconn *DBCon;
> 		PGresult *DBResult;
> 
> 		//Connect to the database with default settings
> 		DBCon = PQsetdbLogin(NULL, NULL, NULL, NULL, "test1",
> "postgres", ""); //test1 is database created with UNICODE encoding
> 
> 		//check if there is any error in connecting to the database
> 		if(PQstatus(DBCon) == CONNECTION_BAD)
> 		{
> 			fprintf(stderr,"\nGetAttributeInfo(): Connection to
> database failed.");
> 			fprintf(stderr,"\nGetAttributeInfo(): %s",
> PQerrorMessage(DBCon));
> 			return ERROR_DB_CON;
> 		}
> 		else
> 		{
> 			fprintf(stderr,"\nGetAttributeInfo(): Connection to
> database successful.");
> 		}
> 		
> 		//form the DELETE command as character buffer.
> 		//swprintf(szQuery,500,L"INSERT INTO gsnames
> values('×¢²á',2,2)");
> 		sprintf(szQuery,"INSERT INTO gsnames values('×¢²á',2,2)");
> 
> 		//execute the command.
> 		DBResult = PQexec(DBCon, (char *)szQuery);
> 
> 		//check for any errors in executing the query.
> 		if(PQresultStatus(DBResult) != PGRES_COMMAND_OK)
> 		{
> 			fprintf(stderr,"\nGetAttributeInfo(): %s",
> PQresultErrorMessage(DBResult));
> 			PQclear(DBResult);
> 			PQfinish(DBCon);
> 			return ERROR_DB_EXEC;
> 		}
> 		else
> 		{
> 			fprintf(stderr,"\nDBInsertPointAttribute():
> Insertion successful. No. of rows affected = %d.", PQntuples(DBResult));
> 		}
> 
> 		PQclear(DBResult);
> 		PQfinish(DBCon);
> 
> 		return 0;
> 	}
> 
> 	The problem is I am not able to pass multibyte characters to
> postgres. Please help.....Thanks 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
> 
> 

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: FW: Libpq - multibyte character support
  2005-09-06 14:29 FW: Libpq - multibyte character support Pradeepkumar, Pyatalo (IE10) <Pradeepkumar.Pyatalo@honeywell.com>
@ 2005-09-07 05:03 ` Miguel Higuera <miguelstratoss@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Miguel Higuera @ 2005-09-07 05:03 UTC (permalink / raw)
  To: Pradeepkumar, Pyatalo (IE10) <Pradeepkumar.Pyatalo@honeywell.com>; pgsql-admin

CREATE DATABASE name ENCODING = WIN1256

THIS MAY BE THE SOLUTION
ALSO YOU CAN PROBE WITH :
ALT, LATIN1 TO LATIN9, EUC_CN, EUC_JP,EUCCREATE DATABASE name ENCODING = 
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) <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]; 
>       char szQuery[255]; 
>       
>       PGconn *DBCon; 
>       PGresult *DBResult; 
>       
>       //Connect to the database with default settings 
>       DBCon = PQsetdbLogin(NULL, NULL, NULL, NULL, "test1", 
>       "postgres", ""); //test1 is database created with UNICODE encoding
>       
>       //check if there is any error in connecting to the database 
>       if(PQstatus(DBCon) == CONNECTION_BAD) 
>       { 
>       fprintf(stderr,"\nGetAttributeInfo(): Connection to database 
>       failed."); 
>       fprintf(stderr,"\nGetAttributeInfo(): %s", 
>       PQerrorMessage(DBCon)); 
>       return ERROR_DB_CON; 
>       } 
>       else 
>       { 
>       fprintf(stderr,"\nGetAttributeInfo(): Connection to database 
>       successful."); 
>       } 
>       
>       //form the DELETE command as character buffer. 
>       //swprintf(szQuery,500,L"INSERT INTO gsnames 
>       values('×¢²á',2,2)"); 
>       sprintf(szQuery,"INSERT INTO gsnames values('×¢²á',2,2)"); 
>       
>       //execute the command. 
>       DBResult = PQexec(DBCon, (char *)szQuery); 
>       
>       //check for any errors in executing the query. 
>       if(PQresultStatus(DBResult) != PGRES_COMMAND_OK) 
>       { 
>       fprintf(stderr,"\nGetAttributeInfo(): %s", 
>       PQresultErrorMessage(DBResult)); 
>       PQclear(DBResult); 
>       PQfinish(DBCon); 
>       return ERROR_DB_EXEC; 
>       } 
>       else 
>       { 
>       fprintf(stderr,"\nDBInsertPointAttribute(): Insertion 
>       successful. No. of rows affected = %d.", PQntuples(DBResult));
>       
>       } 
>       
>       PQclear(DBResult); 
>       PQfinish(DBCon); 
>       
>       return 0; 
>       } 
>       
>       The problem is I am not able to pass multibyte characters to 
>       postgres. Please help.....Thanks 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 
>       
>       
>

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: FW: Libpq - multibyte character support
@ 2005-09-07 06:10 Pradeepkumar, Pyatalo (IE10) <Pradeepkumar.Pyatalo@honeywell.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Pradeepkumar, Pyatalo (IE10) @ 2005-09-07 06:10 UTC (permalink / raw)
  To: Miguel Higuera <miguelstratoss@gmail.com>; Pradeepkumar, Pyatalo (IE10) <Pradeepkumar.Pyatalo@honeywell.com>; pgsql-admin

The problem that I am facing is not with creating the database to support
multi bytes. I have a code written in C/C++. I am using libpq functions to
do the database operations. But the problem is the libpq functions accept
the database queries only in the form of char * . It does not accept wchar_t
* If i have to execute a query say "SELECT * FROM GSNAMES WHERE GSName =
'some chinese_string'"....i am not able to pass the paramater to the libpq
function PQexe(PGconn *, char *). I need help regarding this.

  _____  

From: Miguel Higuera [mailto:miguelstratoss@gmail.com] 
Sent: Wednesday, September 07, 2005 10:34 AM
To: Pradeepkumar, Pyatalo (IE10); pgsql-admin@postgresql.org
Subject: Re: [ADMIN] FW: Libpq - multibyte character support


CREATE DATABASE name ENCODING = WIN1256

THIS MAY BE THE SOLUTION
ALSO YOU CAN PROBE WITH :
ALT, LATIN1 TO LATIN9, EUC_CN, EUC_JP,EUCCREATE DATABASE name ENCODING =
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) <Pradeepkumar.Pyatalo@honeywell.com
<mailto: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]; 
        char szQuery[255]; 

	        PGconn *DBCon; 
        PGresult *DBResult; 

	        //Connect to the database with default settings 
        DBCon = PQsetdbLogin(NULL, NULL, NULL, NULL, "test1", "postgres",
""); //test1 is database created with UNICODE encoding 

	        //check if there is any error in connecting to the database 
        if(PQstatus(DBCon) == CONNECTION_BAD) 
        { 
                fprintf(stderr,"\nGetAttributeInfo(): Connection to database
failed."); 
                fprintf(stderr,"\nGetAttributeInfo(): %s",
PQerrorMessage(DBCon)); 
                return ERROR_DB_CON; 
        } 
        else 
        { 
                fprintf(stderr,"\nGetAttributeInfo(): Connection to database
successful."); 
        } 
        
        //form the DELETE command as character buffer. 
        //swprintf(szQuery,500,L"INSERT INTO gsnames values('×¢²á',2,2)"); 
        sprintf(szQuery,"INSERT INTO gsnames values('×¢²á',2,2)"); 

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

	        //check for any errors in executing the query. 
        if(PQresultStatus(DBResult) != PGRES_COMMAND_OK) 
        { 
                fprintf(stderr,"\nGetAttributeInfo(): %s",
PQresultErrorMessage(DBResult)); 
                PQclear(DBResult); 
                PQfinish(DBCon); 
                return ERROR_DB_EXEC; 
        } 
        else 
        { 
                fprintf(stderr,"\nDBInsertPointAttribute(): Insertion
successful. No. of rows affected = %d.", PQntuples(DBResult));

	        } 

	        PQclear(DBResult); 
        PQfinish(DBCon); 

	        return 0; 
} 

	The problem is I am not able to pass multibyte characters to
postgres. Please help.....Thanks 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 

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2005-09-07 06:10 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-09-06 14:29 FW: Libpq - multibyte character support Pradeepkumar, Pyatalo (IE10) <Pradeepkumar.Pyatalo@honeywell.com>
2005-09-07 05:03 ` Miguel Higuera <miguelstratoss@gmail.com>
2005-09-07 06:10 Re: FW: Libpq - multibyte character support Pradeepkumar, Pyatalo (IE10) <Pradeepkumar.Pyatalo@honeywell.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox