pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: W. de Hoog <wdehoog@exalondelft.nl>
To: pgsql-odbc@postgresql.org
Subject: problem converting ucs2 to utf8
Date: Sat, 21 Sep 2013 18:17:29 +0200
Message-ID: <523DC699.8060509@exalondelft.nl> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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


-- 
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc



Message-ID: <523DC699.8060509@exalondelft.nl>
Permalink:  ../523DC699.8060509@exalondelft.nl/
Also on:    postgresql.org/message-id/523DC699.8060509@exalondelft.nl

 · 

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: wdehoog@exalondelft.nl
  Subject: Re: problem converting ucs2 to utf8
  In-Reply-To: <523DC699.8060509@exalondelft.nl>
  References: <523DC699.8060509@exalondelft.nl>

* 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