BUG #8210: UTF8 column names corrupted by server
От | martin.schaefer@cadcorp.com |
---|---|
Тема | BUG #8210: UTF8 column names corrupted by server |
Дата | |
Msg-id | E1Uk7c5-0001IJ-KP@wrigleys.postgresql.org обсуждение исходный текст |
Список | pgsql-bugs |
The following bug has been logged on the website: Bug reference: 8210 Logged by: Martin Schaefer Email address: martin.schaefer@cadcorp.com PostgreSQL version: 9.2.1 Operating system: Windows 8 Description: = The following code: const wchar_t *strName =3D L"id_=C3=A4=C3=9F"; wstring strCreate =3D wstring(L"create table test_umlaut(") + strName += L" integer primary key)"; PGconn *pConn =3D PQsetdbLogin("", "", NULL, NULL, "dev503", "postgres", "******"); if (!pConn) FAIL; if (PQsetClientEncoding(pConn, "UTF-8")) FAIL; PGresult *pResult =3D PQexec(pConn, "drop table test_umlaut"); if (pResult) PQclear(pResult); pResult =3D PQexec(pConn, ToUtf8(strCreate.c_str()).c_str()); if (pResult) PQclear(pResult); pResult =3D PQexec(pConn, "select * from test_umlaut"); if (!pResult) FAIL; if (PQresultStatus(pResult)!=3DPGRES_TUPLES_OK) FAIL; if (PQnfields(pResult)!=3D1) FAIL; const char *fName =3D 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_=C3=A4=C3=9F in UTF8: id_=C3=83=C2=A4=C3=83=C5=B8 from DB: id_=C3=A3=C2=A4=C3=A3=C3=BF 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=E2=80=99m using PostgreSQL 9.2.1, compiled by Visual C++ build 1600, 64-b= it The database uses: ENCODING =3D 'UTF8' LC_COLLATE =3D 'English_United Kingdom.1252' LC_CTYPE =3D 'English_United Kingdom.1252'
В списке pgsql-bugs по дате отправления: