PostgresDAC

TPSQLDatabase.Properties.CharSet

Previous Next

To set client encoding for the connection.

Syntax:

property CharSet: string;

Description:

The character set support in PostgreSQL allows you to store text in a variety of character sets, including single-byte character sets such as the ISO 8859 series and multiple-byte character sets such as EUC (Extended Unix Code), Unicode, and Mule internal code. All character sets can be used transparently throughout the server. The default character set is selected while initializing your PostgreSQL database cluster. It can be overridden when you create a database. So you can have multiple databases each with a different character set.

Server Character SetsDescription
SQL_ASCIIASCII
EUC_JPJapanese EUC
EUC_CNChinese EUC
EUC_KRKorean EUC
JOHABKorean EUC (Hangle base)
EUC_TWTaiwan EUC
UNICODEUnicode (UTF-8)
MULE_INTERNALMule internal code
LATIN1ISO 8859-1/ECMA 94 (Latin alphabet no.1)
LATIN2ISO 8859-2/ECMA 94 (Latin alphabet no.2)
LATIN3ISO 8859-3/ECMA 94 (Latin alphabet no.3)
LATIN4ISO 8859-4/ECMA 94 (Latin alphabet no.4)
LATIN5ISO 8859-9/ECMA 128 (Latin alphabet no.5)
LATIN6ISO 8859-10/ECMA 144 (Latin alphabet no.6)
LATIN7ISO 8859-13 (Latin alphabet no.7)
LATIN8ISO 8859-14 (Latin alphabet no.8)
LATIN9ISO 8859-15 (Latin alphabet no.9)
LATIN10ISO 8859-16/ASRO SR 14111 (Latin alphabet no.10)
ISO_8859_5ISO 8859-5/ECMA 113 (Latin/Cyrillic)
ISO_8859_6ISO 8859-6/ECMA 114 (Latin/Arabic)
ISO_8859_7ISO 8859-7/ECMA 118 (Latin/Greek)
ISO_8859_8ISO 8859-8/ECMA 121 (Latin/Hebrew)
KOI8KOI8-R(U)
ALTWindows CP866
WIN874Windows CP874 (Thai)
WIN1250Windows CP1250
WINWindows CP1251
WIN1256Windows CP1256 (Arabic)
TCVNTCVN-5712/Windows CP1258 (Vietnamese)
Property contains empty string if TPSQLdatabase.Connected is False. Value of CharSet property will be not saved in form files. For every session you must specify CharSet value again.

Example:

This code will set UNICODE charset for session immediatly after connect.

procedure TForm1.PSQLDatabase1AfterConnect(Sender: TObject);
begin
 PSQLDatabase1.CharSet := 'UNICODE';
end;
Before PostgreSQL 7.2, LATIN5 mistakenly meant ISO 8859-5. From 7.2 on, LATIN5 means ISO 8859-9. If you have a LATIN5 database created on 7.1 or earlier and want to migrate to 7.2 or later, you should be careful about this change.