problem converting ucs2 to utf8

From: "W(dot) de Hoog" <wdehoog(at)exalondelft(dot)nl>
To: pgsql-odbc(at)postgresql(dot)org
Subject: problem converting ucs2 to utf8
Date: 2013-09-21 16:17:29
Message-ID: 523DC699.8060509@exalondelft.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

Hi,

I am trying to connect postgres to mono on ubuntu 64 bits. There is a
problem when converting wchar data from a bound parameter. The call to
ucs2_to_utf8 in convert.c always fails. Doing some mylog stuff I noticed
the passed parameters behave weird. The output of (wj is an int).

mylog("wj C_WCHAR=%s used=%d, WCLEN=%d\n", buffer, used, WCLEN);
mylog(" used stuff: %d:%d:%d\n", used > 0, used / WCLEN, used > 0 ?
used / WCLEN : used);
wj = used;
mylog(" more used stuff: %d:%d:%d\n", wj > 0, wj / WCLEN, wj > 0 ? wj /
WCLEN : wj);

is

[140667133007808]wj C_WCHAR=b used=-3, WCLEN=2
[140667133007808] used stuff: 1:2147483646:2147483646
[140667133007808] more used stuff: 0:-2:-3

so ucs2_to_utf8 does not alloc any space and the operation fails.

When I change the call to
buf = allocbuf = ucs2_to_utf8((SQLWCHAR *) buffer, wj, &wj, FALSE);
used = wj;

it seems to work.

Anybody an idea what went wrong with the content of the 'used' variable
here?

regards,

--
Willem-Jan de Hoog

Browse pgsql-odbc by date

  From Date Subject
Next Message Jan-Peter Seifert 2013-09-25 08:35:09 Re: OIDs > 2147483647 still a problem for the Unicode version ( 32 bit ) ?
Previous Message Barry Bell 2013-09-03 20:07:55 FW: Postgres driver AB=8