pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedPQexecParams and wchar_t
3+ messages / 3 participants
[nested] [flat]
* PQexecParams and wchar_t
@ 2007-08-21 20:03 Rob <motorhead9876@yahoo.com>
2007-08-21 20:33 ` Re: PQexecParams and wchar_t Jeroen T. Vermeulen <jtv@xs4all.nl>
2007-08-22 02:46 ` Re: PQexecParams and wchar_t slakr <ac@esilo.com>
0 siblings, 2 replies; 3+ messages in thread
From: Rob @ 2007-08-21 20:03 UTC (permalink / raw)
To: pgsql-interfaces
Does anyone have an example of passing a UTF8 wchar_t character string to PQexecParams() working? For the life of me I can't get it to work. The best I've gotten is the first character of the string is added to my table.
The database uses UTF8 encoding, but no combination of parameters to PQexecParams that I've found gets the whole string into my function. I'm guessing that since that PQexecParams takes an array of const char * that the interface has no way to guess that the parameters are actually wide characters. And since (for english encoding) the data is stored in the first byte of the two byte character, the interface only grabs the first byte of the wide string, thinking the second byte is a null terminator.
Specifying the length of the wchar parameter makes no difference. Is there any way to tell the interface that the parameter is a wide character string?
Any help greatly appreciated.
Rob
---------------------------------
Pinpoint customers who are looking for what you sell.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: PQexecParams and wchar_t
2007-08-21 20:03 PQexecParams and wchar_t Rob <motorhead9876@yahoo.com>
@ 2007-08-21 20:33 ` Jeroen T. Vermeulen <jtv@xs4all.nl>
1 sibling, 0 replies; 3+ messages in thread
From: Jeroen T. Vermeulen @ 2007-08-21 20:33 UTC (permalink / raw)
To: Rob <motorhead9876@yahoo.com>; +Cc: pgsql-interfaces
On Wed, August 22, 2007 03:03, Rob wrote:
> Does anyone have an example of passing a UTF8 wchar_t character string to
> PQexecParams() working? For the life of me I can't get it to work. The
> best I've gotten is the first character of the string is added to my
> table.
Why would you want to use wchar_t for UTF-8? And how?
Jeroen
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: PQexecParams and wchar_t
2007-08-21 20:03 PQexecParams and wchar_t Rob <motorhead9876@yahoo.com>
@ 2007-08-22 02:46 ` slakr <ac@esilo.com>
1 sibling, 0 replies; 3+ messages in thread
From: slakr @ 2007-08-22 02:46 UTC (permalink / raw)
To: pgsql-interfaces
I have never heard of using a wchar_t for UTF8. If you have a wchar_t
string, its probably utf-16 or ucs4 encoding. You need to convert it to
utf8: iconv on most unixes or WideCharToMultiByte on windows. That will
give you a char array that PQexecParams will understand.
slakr
UngaWunga wrote:
>
> Does anyone have an example of passing a UTF8 wchar_t character string to
> PQexecParams() working? For the life of me I can't get it to work. The
> best I've gotten is the first character of the string is added to my
> table.
>
> The database uses UTF8 encoding, but no combination of parameters to
> PQexecParams that I've found gets the whole string into my function. I'm
> guessing that since that PQexecParams takes an array of const char * that
> the interface has no way to guess that the parameters are actually wide
> characters. And since (for english encoding) the data is stored in the
> first byte of the two byte character, the interface only grabs the first
> byte of the wide string, thinking the second byte is a null terminator.
>
> Specifying the length of the wchar parameter makes no difference. Is there
> any way to tell the interface that the parameter is a wide character
> string?
>
> Any help greatly appreciated.
>
> Rob
>
>
>
> ---------------------------------
> Pinpoint customers who are looking for what you sell.
>
--
View this message in context: http://www.nabble.com/PQexecParams-and-wchar_t-tf4307500.html#a12267175
Sent from the PostgreSQL - interfaces mailing list archive at Nabble.com.
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2007-08-22 02:46 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-08-21 20:03 PQexecParams and wchar_t Rob <motorhead9876@yahoo.com>
2007-08-21 20:33 ` Jeroen T. Vermeulen <jtv@xs4all.nl>
2007-08-22 02:46 ` slakr <ac@esilo.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