GETDATABASEENCODING()

Return the database encoding for the current database.
GETDATABASEENCODING()
For example:
premdb=# select getdatabaseencoding();
 getdatabaseencoding 
---------------------
 LATIN9
(1 row)

premdb=# create database premdb_utf8 encoding 'utf8';
CREATE DATABASE
premdb=# \c premdb_utf8
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
You are now connected to database "premdb_utf8" as user "yellowbrick".
premdb_utf8=# select getdatabaseencoding();
 getdatabaseencoding 
---------------------
 UTF8
(1 row)

See also CREATE DATABASE.