diff options
-rw-r--r-- | it_dbi_postgres.class | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/it_dbi_postgres.class b/it_dbi_postgres.class index e96a46d..6b60fb4 100644 --- a/it_dbi_postgres.class +++ b/it_dbi_postgres.class @@ -100,10 +100,12 @@ function _connect_db($p) { if ($result) { - # set charset used for this connection - if ($p['charset']) - if (!pg_set_client_encoding($result, $p['charset'])) - $this->_fatal("_connect(): can't set charset \"{$p['charset']}\""); + # set charset used for this connection (also change mariadb specific default utf8mb4 to utf8) + if ($p['charset']) { + $charset = $p['charset'] == 'utf8mb4' ? 'UNICODE' : $p['charset']; + if (pg_set_client_encoding($result, $charset) < 0) + $this->_fatal("_connect(): can't set charset \"$charset\""); + } } return [$result, $result ? '' : 'Could not connect']; |