Thread: Character Set UTF8 and libpq

Character Set UTF8 and libpq

From
"Nagle, Gail A \(US SSA\)"
Date:

Suppose a database is created to use UTF8 encoding using the following command:

               createdb -E UTF8 customers

 

Further suppose that a table is created consisting of two columns, cust_name of type text, and cust_number of type integer.

 

Later, the customers database is accessed programmatically by the  PQexec() or PqexecParams() methods, each of which take a const char *command parameter.  In the program the value of the char* command parameter is built up sequentially by appending bytes to an array of unsigned char. For example, the value could be created by concatenatingINSERT INTO mytable VALUES(" with a unicode valued array for the cust_name column and a simple ascii string for the cust_number.
 
My question is does the entire string, i.e. “INSERT INTO mytable VALUES(" and the integer value need to be UTF8 encoded or can these parts be in plain ascii text?
 
Thank you,
Gail

Re: Character Set UTF8 and libpq

From
Tom Lane
Date:
"Nagle, Gail A \(US SSA\)" <gail.nagle@baesystems.com> writes:
> My question is does the entire string, i.e. "INSERT INTO mytable
> VALUES(" and the integer value need to be UTF8 encoded or can these
> parts be in plain ascii text?

Huh?  ASCII text is perfectly legal UTF8.

            regards, tom lane

Re: Character Set UTF8 and libpq

From
"Nagle, Gail A \(US SSA\)"
Date:
Thanks - sorry for the dumb question.

-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Monday, January 05, 2009 6:13 PM
To: Nagle, Gail A (US SSA)
Cc: pgsql-novice@postgresql.org
Subject: Re: [NOVICE] Character Set UTF8 and libpq

"Nagle, Gail A \(US SSA\)" <gail.nagle@baesystems.com> writes:
> My question is does the entire string, i.e. "INSERT INTO mytable
> VALUES(" and the integer value need to be UTF8 encoded or can these
> parts be in plain ascii text?

Huh?  ASCII text is perfectly legal UTF8.

            regards, tom lane