pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Please help - libpq API
5+ messages / 4 participants
[nested] [flat]

* Please help - libpq API
@ 2005-09-08 06:40 Pradeepkumar, Pyatalo (IE10) <Pradeepkumar.Pyatalo@honeywell.com>
  2005-09-08 10:22 ` Re: Please help - libpq API Guido Barosio <gbarosio@gmail.com>
  2005-09-08 13:25 ` Re: Please help - libpq API Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 2 replies; 5+ messages in thread

From: Pradeepkumar, Pyatalo (IE10) @ 2005-09-08 06:40 UTC (permalink / raw)
  To: pgsql-admin; pgsql-novice@postgresql.org


Hi all,

I have already posted my query regarding libpq functions and wide character
support. Pls somebody help me. I am using libpq API functions in my C code
to do operations on the database. But the problem I m facing is API
functions like PQexec() etc....accept only char * .... but as part of
localization, the queries I want to executed contain chinese characters
which are multibytes. So the queries I want to execute are in wchar_t *
format and PQ exec() accepts only char *. Is there any alternate way to
execute queries having wide characters. 

Even if somehow if I convert wchar_t *  to char * and provide it to
Postgres, how will it differentiate between chinese characters and normal
characters ??

Please help !!

Regs,
Pradeep


> This e-mail and any attachments thereto, are intended only for use by the
> addressee(s) named herein and contain Honeywell confidential information.
> If you are not the intended recipient of this e-mail, you are hereby
> notified that any dissemination, distribution or copying which amounts to
> misappropriation of this e-mail and any attachments thereto, is strictly
> prohibited. If you have received this e-mail in error, please immediately
> notify me and permanently delete the original and any copy of any e-mail
> and any printout thereof." 
> 
> 

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

* Re: Please help - libpq API
  2005-09-08 06:40 Please help - libpq API Pradeepkumar, Pyatalo (IE10) <Pradeepkumar.Pyatalo@honeywell.com>
@ 2005-09-08 10:22 ` Guido Barosio <gbarosio@gmail.com>
  1 sibling, 0 replies; 5+ messages in thread

From: Guido Barosio @ 2005-09-08 10:22 UTC (permalink / raw)
  To: Pradeepkumar, Pyatalo (IE10) <Pradeepkumar.Pyatalo@honeywell.com>; +Cc: pgsql-admin; pgsql-novice@postgresql.org

Hi,

I think that this is the wrong list for your problem. My suggestions:

contact pgsql-hackers or check the lists in the
postgresql.org<http://postgresql.org>page, you will prolly find one
list to suit with this.
or
irc.freenode.net <http://irc.freenode.net;, join #postgresql . Good boys 
lurking there, you will have to fight, but help will be given if you have 
good maners and offer a pizza.

Good luck.

G.-

On 9/8/05, Pradeepkumar, Pyatalo (IE10) <Pradeepkumar.Pyatalo@honeywell.com> 
wrote:
> 
> 
> Hi all, 
> 
> I have already posted my query regarding libpq functions and wide 
> character support. Pls somebody help me. I am using libpq API functions in 
> my C code to do operations on the database. But the problem I m facing is 
> API functions like PQexec() etc....accept only char * .... but as part of 
> localization, the queries I want to executed contain chinese characters 
> which are multibytes. So the queries I want to execute are in wchar_t * 
> format and PQ exec() accepts only char *. Is there any alternate way to 
> execute queries having wide characters. 
> 
> Even if somehow if I convert wchar_t * to char * and provide it to 
> Postgres, how will it differentiate between chinese characters and normal 
> characters ??
> 
> Please help !! 
> 
> Regs, 
> Pradeep 
> 
> 
>    This e-mail and any attachments thereto, are intended only for use 
>    by the addressee(s) named herein and contain Honeywell confidential 
>    information. If you are not the intended recipient of this e-mail, you are 
>    hereby notified that any dissemination, distribution or copying which 
>    amounts to misappropriation of this e-mail and any attachments thereto, is 
>    strictly prohibited. If you have received this e-mail in error, please 
>    immediately notify me and permanently delete the original and any copy of 
>    any e-mail and any printout thereof." 
>    
>    
> 


-- 
"Adopting the position that you are smarter than an automatic
optimization algorithm is generally a good way to achieve less
performance, not more" - Tom Lane.

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

* Re: Please help - libpq API
  2005-09-08 06:40 Please help - libpq API Pradeepkumar, Pyatalo (IE10) <Pradeepkumar.Pyatalo@honeywell.com>
@ 2005-09-08 13:25 ` Alvaro Herrera <alvherre@alvh.no-ip.org>
  2005-09-08 16:47   ` Re: Please help - libpq API Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 1 reply; 5+ messages in thread

From: Alvaro Herrera @ 2005-09-08 13:25 UTC (permalink / raw)
  To: Pradeepkumar, Pyatalo (IE10) <Pradeepkumar.Pyatalo@honeywell.com>; +Cc: pgsql-admin; pgsql-novice@postgresql.org

On Wed, Sep 07, 2005 at 11:40:57PM -0700, Pradeepkumar, Pyatalo (IE10) wrote:

> I have already posted my query regarding libpq functions and wide character
> support. Pls somebody help me. I am using libpq API functions in my C code
> to do operations on the database. But the problem I m facing is API
> functions like PQexec() etc....accept only char * .... but as part of
> localization, the queries I want to executed contain chinese characters
> which are multibytes. So the queries I want to execute are in wchar_t *
> format and PQ exec() accepts only char *. Is there any alternate way to
> execute queries having wide characters. 

I think you could be using PQexecParams() and passing your wide-char
strings as binary parameters somehow.  I don't really know if this will
work or not, but it may give you an idea.  But note below:

> Even if somehow if I convert wchar_t *  to char * and provide it to
> Postgres, how will it differentiate between chinese characters and normal
> characters ??

Please note that any string you pass from the client will be interpreted
using the client_encoding setting.  So maybe what you have to do is just
set client_encoding to the encoding that the strings are encoded in.  If
you choose the wrong client_encoding, the server may recode the
characters inappropiately, or not at all, and thus insert wrong data.

Please see the documentation.

-- 
Alvaro Herrera -- Valdivia, Chile         Architect, www.EnterpriseDB.com
"When the proper man does nothing (wu-wei),
his thought is felt ten thousand miles." (Lao Tse)



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

* Re: Please help - libpq API
  2005-09-08 06:40 Please help - libpq API Pradeepkumar, Pyatalo (IE10) <Pradeepkumar.Pyatalo@honeywell.com>
  2005-09-08 13:25 ` Re: Please help - libpq API Alvaro Herrera <alvherre@alvh.no-ip.org>
@ 2005-09-08 16:47   ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2005-09-08 16:47 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@alvh.no-ip.org>; +Cc: Pradeepkumar, Pyatalo (IE10) <Pradeepkumar.Pyatalo@honeywell.com>; pgsql-admin; pgsql-novice@postgresql.org

Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
> On Wed, Sep 07, 2005 at 11:40:57PM -0700, Pradeepkumar, Pyatalo (IE10) wrote:
>> Even if somehow if I convert wchar_t *  to char * and provide it to
>> Postgres, how will it differentiate between chinese characters and normal
>> characters ??

> Please note that any string you pass from the client will be interpreted
> using the client_encoding setting.  So maybe what you have to do is just
> set client_encoding to the encoding that the strings are encoded in.

I think his problem is that his data is represented in UCS2 or UCS4
(or some other fixed-width representation) and we don't support those
as client_encoding values AFAIK.  He'll need to do an encoding
conversion to some representation we do support, such as UTF8.

			regards, tom lane



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

* Re: Please help - libpq API
@ 2005-09-12 03:00 Pradeepkumar, Pyatalo (IE10) <Pradeepkumar.Pyatalo@honeywell.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Pradeepkumar, Pyatalo (IE10) @ 2005-09-12 03:00 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; Alvaro Herrera <alvherre@alvh.no-ip.org>; +Cc: Pradeepkumar, Pyatalo (IE10) <Pradeepkumar.Pyatalo@honeywell.com>; pgsql-admin; pgsql-novice@postgresql.org


Hi all,

Thanks for all your patience and help. I really appreciate this group as I
have always found someone or the other replying to my questions. For my
problem, I set the client and server encoding to UNICODE. The problem that
libpq functions does not support wide characters still remains. I am
converting the wide character strings to proper UTF-8 format and passing it
to the libpq functions. But I still feel that libpq functions should support
wide character datatypes also.

Regs,
Pradeep 

-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us] 
Sent: Thursday, September 08, 2005 10:17 PM
To: Alvaro Herrera
Cc: Pradeepkumar, Pyatalo (IE10); pgsql-admin@postgresql.org;
pgsql-novice@postgresql.org
Subject: Re: [ADMIN] Please help - libpq API 

Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
> On Wed, Sep 07, 2005 at 11:40:57PM -0700, Pradeepkumar, Pyatalo (IE10)
wrote:
>> Even if somehow if I convert wchar_t *  to char * and provide it to 
>> Postgres, how will it differentiate between chinese characters and 
>> normal characters ??

> Please note that any string you pass from the client will be 
> interpreted using the client_encoding setting.  So maybe what you have 
> to do is just set client_encoding to the encoding that the strings are
encoded in.

I think his problem is that his data is represented in UCS2 or UCS4 (or some
other fixed-width representation) and we don't support those as
client_encoding values AFAIK.  He'll need to do an encoding conversion to
some representation we do support, such as UTF8.

			regards, tom lane



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


end of thread, other threads:[~2005-09-12 03:00 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-09-08 06:40 Please help - libpq API Pradeepkumar, Pyatalo (IE10) <Pradeepkumar.Pyatalo@honeywell.com>
2005-09-08 10:22 ` Guido Barosio <gbarosio@gmail.com>
2005-09-08 13:25 ` Alvaro Herrera <alvherre@alvh.no-ip.org>
2005-09-08 16:47   ` Tom Lane <tgl@sss.pgh.pa.us>
2005-09-12 03:00 Re: Please help - libpq API 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