Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id EE06D9F99F3 for ; Tue, 21 Aug 2007 23:46:56 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 42144-01 for ; Tue, 21 Aug 2007 23:46:53 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from kuber.nabble.com (kuber.nabble.com [216.139.236.158]) by postgresql.org (Postfix) with ESMTP id BBB9A9F9993 for ; Tue, 21 Aug 2007 23:46:53 -0300 (ADT) Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1INgF9-0005cQ-TT for pgsql-interfaces@postgresql.org; Tue, 21 Aug 2007 19:46:51 -0700 Message-ID: <12267175.post@talk.nabble.com> Date: Tue, 21 Aug 2007 19:46:51 -0700 (PDT) From: slakr To: pgsql-interfaces@postgresql.org Subject: Re: PQexecParams and wchar_t In-Reply-To: <736324.21426.qm@web54606.mail.re2.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: ac@esilo.com References: <736324.21426.qm@web54606.mail.re2.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.889 tagged_above=0 required=5 tests=BAYES_20=-0.74, DNS_FROM_OPENWHOIS=1.13, WHOIS_MYPRIVREG=1.499 X-Spam-Level: * X-Archive-Number: 200708/9 X-Sequence-Number: 6603 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.