Getting the encoding of a Postgres database
Method 1:
If you're already logged in to the db server, just copy and paste this.
SHOW SERVER_ENCODING;
Result:
server_encoding
-----------------
UTF8
For Client encoding :
SHOW CLIENT_ENCODING;
Method 2:
Again if you are already logged in, use this to get the list based result
\l
From the command line:
psql my_database -c 'SHOW SERVER_ENCODING'
From within psql
, an SQL IDE or an API:
SHOW SERVER_ENCODING;