This section explains the language settings for the application runtime environment and the encoding settings for the application.
You must match the language settings for the application runtime environment with the message locale settings of the database server.
Messages output by an application may include text from messages sent from the database server. In the resulting text, the text of the application message will use the message locale of the application, and the text of the message sent by the database server will use the message locale of the database server. If the message locales do not match, more than one language or encoding system will be used. Moreover, if the encoding systems do not match, characters in the resulting text can be garbled.
Linux
Set the locale for messages (LC_MESSAGES category) to match the message locale of the database server. This can be done in a few different ways, such as using environment variables. Refer to the relevant manual of the operating system for information on the setlocale function.
Example
Example of specifying "en_US.UTF-8" with the setlocale function
setlocale(LC_ALL,"en_US.UTF-8");
Specifying the locale of the LC_ALL category propagates the setting to LC_MESSAGE.
Windows(R)
Align the locale of the operating system with the message locale of the database server.
Ensure that the encoding system that is embedded in the application and passed to the database, and the encoding system setting of the runtime environment, are the same. The encoding system cannot be converted correctly on the database server.
Use one of the following methods to set the encoding system for the application:
Set the PGCLIENTENCODING environment variable in the runtime environment.
Set the client_encoding keyword in the connection string.
Use the PQsetClientEncoding function.
See
Refer to "Supported Character Sets" in "Server Administration" in the PostgreSQL Documentation for information on the strings that represent the encoding system that can be set.
For example, when using "Unicode" and "8 bit", set the string "UTF8".
Note
Text may be garbled when outputting results to the command prompt. Review the font settings for the command prompt if this occurs.