The following bug has been logged on the website: Bug reference: 8210 Logged by: Martin Schaefer Email address: martin.schae...@cadcorp.com PostgreSQL version: 9.2.1 Operating system: Windows 8 Description:
The following code: const wchar_t *strName = L"id_äß"; wstring strCreate = wstring(L"create table test_umlaut(") + strName + L" integer primary key)"; PGconn *pConn = PQsetdbLogin("", "", NULL, NULL, "dev503", "postgres", "******"); if (!pConn) FAIL; if (PQsetClientEncoding(pConn, "UTF-8")) FAIL; PGresult *pResult = PQexec(pConn, "drop table test_umlaut"); if (pResult) PQclear(pResult); pResult = PQexec(pConn, ToUtf8(strCreate.c_str()).c_str()); if (pResult) PQclear(pResult); pResult = PQexec(pConn, "select * from test_umlaut"); if (!pResult) FAIL; if (PQresultStatus(pResult)!=PGRES_TUPLES_OK) FAIL; if (PQnfields(pResult)!=1) FAIL; const char *fName = PQfname(pResult,0); ShowW("Name: ", strName); ShowA("in UTF8: ", ToUtf8(strName).c_str()); ShowA("from DB: ", fName); ShowW("in UTF16: ", ToWide(fName).c_str()); PQclear(pResult); PQreset(pConn); (ShowA/W call OutputDebugStringA/W, and ToUtf8/ToWide use WideCharToMultiByte/MultiByteToWideChar with CP_UTF8.) generates this output: Name: id_äß in UTF8: id_äß from DB: id_ã¤ãÿ in UTF16: id_??? The back-end treats the name as if it were in ANSI encoding, not in UTF-8, when it lower-cases the name. The resulting column name is corrupted. I’m using PostgreSQL 9.2.1, compiled by Visual C++ build 1600, 64-bit The database uses: ENCODING = 'UTF8' LC_COLLATE = 'English_United Kingdom.1252' LC_CTYPE = 'English_United Kingdom.1252' -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs