X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 09B7F30EE07 for ; Mon, 16 Jun 2003 10:52:26 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 84085-08 for ; Mon, 16 Jun 2003 07:52:15 -0300 (ADT) Received: from smtp.web.de (smtp02.web.de [217.72.192.151]) by svr1.postgresql.org (Postfix) with ESMTP id 6D36330EE49 for ; Mon, 16 Jun 2003 07:52:15 -0300 (ADT) Received: from p50818844.dip0.t-ipconnect.de ([80.129.136.68] helo=web.de) by smtp.web.de with asmtp (TLSv1:RC4-MD5:128) (WEB.DE 4.98 #232) id 19Rrax-0001zr-00; Mon, 16 Jun 2003 12:52:15 +0200 Message-ID: <3EEDA16B.1010202@web.de> Date: Mon, 16 Jun 2003 12:52:27 +0200 From: Andreas Pflug User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-odbc@postgresql.org, Dave Page Subject: Unicode/client_encoding/conversion problem Content-Type: multipart/mixed; boundary="------------070004060209020503070507" X-Archive-Number: 200306/27 X-Sequence-Number: 3001 This is a multi-part message in MIME format. --------------070004060209020503070507 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hi friends, when a column SQL_C_CHAR is handled in ResolveOneParam, the conversion is coded dependent on param_sqltype. If a SQL_CHAR variable is bound to it, no conversion takes place, which is incorrect. ODBC architecture assumes sqltype to be the server_encoding, but this is irrelevant for pgsql. Instead, everything is done with client_encoding (anything but UNICODE doesn't make sense here), so we need a conversion to UTF-8 in any case. I wonder if the other direction is handled correctly... A patch is attached. Regards, Andreas --------------070004060209020503070507 Content-Type: text/plain; name="ResolveOneParam.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ResolveOneParam.patch" RCS file: /usr/local/cvsroot/psqlodbc/psqlodbc/convert.c,v retrieving revision 1.99 diff -r1.99 convert.c 2560a2561,2565 > /********************* > * it's not correct to convert depending on param_sqltype, > * because the client_encoding is always unicode. > * We need conversion in any case. > 2577a2583,2594 > > */ > > if (SQL_NTS == used) > used = strlen(buffer); > allocbuf = malloc(2 * (used + 1)); > used = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, buffer, > used, (LPWSTR) allocbuf, used + 1); > buf = ucs2_to_utf8((SQLWCHAR *) allocbuf, used, &used); > free(allocbuf); > allocbuf = buf; > --------------070004060209020503070507--