From 02e14562a806a96f38120c96421d39dfa7394192 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Sat, 19 Feb 2011 08:54:58 +0200 Subject: Set psql client encoding from locale by default Add a new libpq connection option client_encoding (which includes the existing PGCLIENTENCODING environment variable), which besides an encoding name accepts a special value "auto" that tries to determine the encoding from the locale in the client's environment, using the mechanisms that have been in use in initdb. psql sets this new connection option to "auto" when running from a terminal and not overridden by setting PGCLIENTENCODING. original code by Heikki Linnakangas, with subsequent contributions by Jaime Casanova, Peter Eisentraut, Stephen Frost, Ibrar Ahmed --- doc/src/sgml/libpq.sgml | 36 +++++++++++++++++++++++++----------- doc/src/sgml/ref/psql-ref.sgml | 11 +++++++++++ 2 files changed, 36 insertions(+), 11 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml index 2d15e78fd08..49edc51dbac 100644 --- a/doc/src/sgml/libpq.sgml +++ b/doc/src/sgml/libpq.sgml @@ -259,6 +259,21 @@ PGconn *PQconnectdbParams(const char **keywords, const char **values, int expand + + client_encoding + + + This sets the client_encoding + configuration parameter for this connection. In addition to + the values accepted by the corresponding server option, you + can use auto to determine the right + encoding from the current locale in the client + (LC_CTYPE environment variable on Unix + systems). + + + + options @@ -6345,6 +6360,16 @@ myEventProc(PGEventId evtId, void *evtInfo, void *passThrough) linkend="libpq-connect-connect-timeout"> connection parameter. + + + + + PGCLIENTENCODING + + PGCLIENTENCODING behaves the same as the connection parameter. + + @@ -6378,17 +6403,6 @@ myEventProc(PGEventId evtId, void *evtInfo, void *passThrough) - - - - PGCLIENTENCODING - - PGCLIENTENCODING sets the default client character - set encoding. (Equivalent to SET client_encoding TO - ....) - - - diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index ff60a72059e..baefb578826 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -593,6 +593,17 @@ $ psql "service=myservice sslmode=require" privileges, server is not running on the targeted host, etc.), psql will return an error and terminate. + + + If at least one of standard input or standard output are a + terminal, then psql sets the client + encoding to auto, which will detect the + appropriate client encoding from the locale settings + (LC_CTYPE environment variable on Unix systems). + If this doesn't work out as expected, the client encoding can be + overridden using the environment + variable PGCLIENTENCODING. + -- cgit v1.2.3