Functions PostgreSQLConnection::ErrorMessage and PostgreSQLSession::ErrorMessage use FromSystemCharset to convert code page. Unfortunately PQerrorMessage AFAIK does not use client's system code page but the code page that is declared in lc_messages (postgresql.conf), or the code page explicit set by the client (function PQsetClientEncoding).
So I think those functions should be modified:
String PostgreSQLConnection::ErrorMessage()
{
// no code page conversion, leave it to postgres
return AsString(PQerrorMessage(conn));
}
String PostgreSQLSession::ErrorMessage()
{
// no code page conversion, leave it to postgres
return AsString(PQerrorMessage(conn));
}
And of course postgres should be informed about the code page: