pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas Pflug <Andreas.Pflug@web.de>
To: Dave Page <dpage@vale-housing.co.uk>
Cc: pgsql-odbc@postgresql.org
Subject: Re: Unicode/client_encoding/conversion problem
Date: Wed, 18 Jun 2003 15:21:38 +0200
Message-ID: <3EF06762.6010507@web.de> (raw)
In-Reply-To: <03AF4E498C591348A42FC93DEA9661B844B0A0@mail.vale-housing.co.uk>
References: <03AF4E498C591348A42FC93DEA9661B844B0A0@mail.vale-housing.co.uk>

Dave Page wrote:

>Thanks, committed with minor fix to close the comment in the correct
>place (pls check).
>
>  
>

Hi Dave,

fix hasn't  made it correctly into the source. The comment was just to 
leave the old code for reference. This probably happened because the 
second fix (ResolveNumeric)  would shift the rows of the first fix.

There's no switch(param_sqltype) needed, instead all code that's under 
the 3 case SQL_xxx is to be executed for unicode. Absolutely wrong is 
the last line "buf=buffer" in the default hieve, because this would 
override the previous conversion.

Attached a new patch file, diff'd from the current cvs.

Regards,
Andreas

Attachments:

ResolveOneParam.patch (text/plain, 1.4K) download RCS file: /usr/local/cvsroot/psqlodbc/psqlodbc/convert.c,v retrieving revision 1.102 diff -r1.102 convert.c 2561,2565d2560 < /********************* < * it's not correct to convert depending on param_sqltype, < * because the client_encoding is always unicode. < * We need conversion in any case. < */ 2569,2594c2564,2571 < switch (param_sqltype) < { < case SQL_WCHAR: < case SQL_WVARCHAR: < case SQL_WLONGVARCHAR: < 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; < break; < default: < < 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; < buf = buffer; < } --- > 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;

view thread (4+ messages)  latest in thread

Message-ID: <3EF06762.6010507@web.de>
Permalink:  ../3EF06762.6010507@web.de/
Also on:    postgresql.org/message-id/3EF06762.6010507@web.de

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: Andreas.Pflug@web.de, dpage@vale-housing.co.uk
  Subject: Re: Unicode/client_encoding/conversion problem
  In-Reply-To: <3EF06762.6010507@web.de>
  References: <03AF4E498C591348A42FC93DEA9661B844B0A0@mail.vale-housing.co.uk> <3EF06762.6010507@web.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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