problem converting ucs2 to utf8 - Mailing list pgsql-odbc

From W. de Hoog
Subject problem converting ucs2 to utf8
Date
Msg-id 523DC699.8060509@exalondelft.nl
Whole thread Raw
List 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


pgsql-odbc by date:

Previous
From: Barry Bell
Date:
Subject: FW: Postgres driver AB=8
Next
From: "Jan-Peter Seifert"
Date:
Subject: Re: OIDs > 2147483647 still a problem for the Unicode version ( 32 bit ) ?