Hi, Tom,
On Sun, Dec 21, 2025 at 9:17 AM Tom Lane <[email protected]> wrote:
>
> Adrian Klaver <[email protected]> writes:
> > It is not the same setup, in your original question you are hand writing
> > code not running a script through the ODBC driver. Best bet is the ODBC
> > driver is picking up the client(Windows) encoding and passing it to the
> > server.
>
> It might be the other way around. psql absolutely will try to infer
> an encoding from its environment, but perhaps the ODBC driver does
> not, or does it differently.
>
> In any case, "SHOW client_encoding" in both the working and
> non-working contexts would yield useful information.
Adding following code:
SQLHSTMT stmt;
SQLWCHAR value[25];
ret = SQLAllocHandle( SQL_HANDLE_STMT, m_hdbc, &stmt );
ret = SQLExecDirect( stmt, L"SHOW client_encoding", SQL_NTS );
ret = SQLBindCol( stmt, 1, SQL_C_WCHAR, &value, 25, 0 );
ret = SQLFetch( stmt );
ret = SQLFreeHandle( SQL_HANDLE_STMT, stmt );
the value of the "value" variable is still "UTF8".
Thank you.
>
> regards, tom lane