Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id BBF4F63292A for ; Mon, 23 Aug 2010 23:09:27 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 57029-04 for ; Tue, 24 Aug 2010 02:09:19 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from www.postnewspapers.com.au (www.postnewspapers.com.au [202.4.227.11]) by mail.postgresql.org (Postfix) with ESMTP id 7097E63244B for ; Mon, 23 Aug 2010 23:09:20 -0300 (ADT) Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by www.postnewspapers.com.au (Postfix) with ESMTP id 5F2A99F69; Tue, 24 Aug 2010 10:09:04 +0800 (WST) Received: from localhost (localhost [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 13DF2AFD6F; Tue, 24 Aug 2010 10:08:46 +0800 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (mail.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 6J6fu8eymJSF; Tue, 24 Aug 2010 10:08:40 +0800 (WST) Received: from [10.1.1.2] (203-206-40-204.dyn.iinet.net.au [203.206.40.204]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTPSA id EC77BAFBAC; Tue, 24 Aug 2010 10:08:39 +0800 (WST) Message-ID: <4C7329C5.4060503@postnewspapers.com.au> Date: Tue, 24 Aug 2010 10:09:09 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100413 Fedora/3.0.4-2.fc13 Thunderbird/3.0.4 MIME-Version: 1.0 To: yufeng230@sina.com CC: pgsql-odbc Subject: Re: pgsqlodbc utf8 windows? References: <20100821030910.CF5EC16A403@mail3-245.sinamail.sina.com.cn> In-Reply-To: <20100821030910.CF5EC16A403@mail3-245.sinamail.sina.com.cn> Content-Type: text/plain; charset=x-gbk; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201008/33 X-Sequence-Number: 10410 On 08/21/2010 11:09 AM, yufeng230@sina.com wrote: > hi: > > In windows,I set postgresql _encoding utf8_ with chinese text inside. > _, when I use psqlodbc-08.04.0200 psqlodbc35w.dll to _connect postgresql > ,but no OK ,read text encoding with UCS2,how to solve it ? UCS2 and utf8 are both unicode encodings. The text should be the same, just encoded differently. The ODBC driver is converting the UTF-8 it gets from PostgreSQL into UCS-2, because that's the standard encoding used by Windows and by the Windows Unicode ODBC driver. If for some reason you really need UTF-8, you should use the standard Windows encoding conversion functions, or use libiconv, to convert from the UCS-2 data you get from the ODBC driver back to UTF-8. Another option is to install the non-unicode ODBC driver for PostgreSQL, which will pass whatever the database sends through to do you directly. That way you should get UTF-8. -- Craig Ringer