X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 50D9AD829B for ; Tue, 6 Sep 2005 14:56:18 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 37952-06 for ; Tue, 6 Sep 2005 17:56:14 +0000 (GMT) Received: from fep02-app.kolumbus.fi (fep02-0.kolumbus.fi [193.229.0.44]) by svr1.postgresql.org (Postfix) with ESMTP id 34189D8270 for ; Tue, 6 Sep 2005 14:56:12 -0300 (ADT) Received: from [192.168.1.101] (really [80.186.85.167]) by fep02-app.kolumbus.fi with ESMTP id <20050906175612.BLWW8199.fep02-app.kolumbus.fi@[192.168.1.101]> for ; Tue, 6 Sep 2005 20:56:12 +0300 Message-ID: <431DD83D.5090106@kolumbus.fi> Date: Tue, 06 Sep 2005 20:56:13 +0300 From: Marko Ristola User-Agent: Debian Thunderbird 1.0.2 (X11/20050817) X-Accept-Language: en-us, en MIME-Version: 1.0 Cc: pgsql-odbc@postgresql.org Subject: Re: Continuing encoding fun.... References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.108 required=5 tests=[AWL=0.058, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200509/73 X-Sequence-Number: 5971 zuschlag2@online.de wrote: >Hi Dave > > > >>It seems to me that the current case is correct - in the Unicode driver >>we *must* run with client_encoding = 'UNICODE' or it won't work >>properly. That said, I wonder if we shouldn't just remove the if() >>altogether, and unconditionally set the client encoding for the Unicode >> >> The following might be interesting for you: If I activate ISO C 99 API, I can do the following: ( I thought, that I used ANSI C 99, but the correct name for the standard, I meant is ISO C 99. It will become default later, maybe it already is with newest GCCs.) char cbuf[500]; wchar_t wbuf[500]; setlocale(LC_CTYPE,""); strcpy(cbuf,"Some multibyte text"); swprintf(wbuf,"%s",cbuf); Now the text is under wchar_t's internal format, maybe UCS-2. The following also works: strcpy(wbuf,L"Some UNICODE text"); sprintf(cbuf,"%ls",wbuf); So, the UCS-2 and multibyte conversion under ISO C 99 seems to be very easy. With GCC, with Debian Sarge, this can be done as follows: gcc -std=c99 I don't have now more time to test, at least today. Iconv seems to be the solution for more advanced conversions under Linux. Regards, Marko