Re: libpq - characterset encoding error from selecting BYTEA

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: CN <cnliou9(at)fastmail(dot)fm>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: libpq - characterset encoding error from selecting BYTEA
Date: 2016-03-15 13:57:11
Message-ID: 18018.1458050231@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

CN <cnliou9(at)fastmail(dot)fm> writes:
> PGconn* first switches to "BIG5" client encoding:
> PQexec(conn,"SET CLIENT_ENCODING TO BIG5");

> version 1:

> const char *pValues[]={"5","6"};
> PGresult *r=PQexecParams(conn,"SELECT c3::BYTEA FROM t1 WHERE c1=$1 AND
> c2=$2",2,NULL,pValues,NULL,NULL,1);

> What is strange is that above PQexecParams() works in one portion of my
> program but in another portion it yields the following error:

> ERROR: character with byte sequence 0x98 0xe1 in encoding "BIG5" has no
> equivalent in encoding "UTF8"

Given the way the complaint is phrased, the problem is with data going
*to* the server, not *from* the server. I don't think the returned bytea
is your issue at all; it must be either in the SQL query string or the
parameter values being sent. Probably you should review how you're
setting up the parameter strings.

regards, tom lane

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message CN 2016-03-15 14:40:07 Re: libpq - characterset encoding error from selecting BYTEA
Previous Message CN 2016-03-15 13:51:11 libpq - characterset encoding error from selecting BYTEA