Enabling support for bidirectional scripts

Bidirectional layout transformations are implemented in Db2® using the new Coded Character Set Identifier (CCSID) definitions. For the new bidirectional-specific CCSIDs, layout transformations are performed instead of, or in addition to, code page conversions. To use this support, the DB2BIDI registry variable must be set to YES. By default, this variable is not set. It is used by the server for all conversions, and can be set only when the server is started. Setting DB2BIDI to YES might have some performance impact because of additional checking and layout transformations.

Before you begin

The following restrictions apply:
  • If you select a CCSID that is not appropriate for the code page or string type of your client platform, you might get unexpected results. If you select an incompatible CCSID (for example, the Latin-1 CCSID for a connection to an Arabic database), or if DB2BIDI has not been set for the server, you will receive an error message when you try to connect.
  • The Db2 Command Line Processor on the Windows operating system does not have bidirectional support.
  • CCSID override is not supported for cases where the HOST EBCDIC platform is the client, and Db2 Database is the server.
When converting from one Arabic CCSID to another Arabic CCSID, Db2 database systems employ the following logic to deshape (or expand) the lam-alef ligature. Deshaping occurs when the Text Shaping attribute of the source Arabic CCSID is shaped but the Text Shaping attribute of the target Arabic CCSID is unshaped.

The logic to deshape the lam-alef ligature is:

  1. If the last character of the data stream is a blank character, then every character after the lam-alef ligature will be shifted to the end of the data stream, therefore making available an empty position for the current lam-alef ligature to be deshaped (expanded) into its two constituent characters: lam and alef.
  2. Otherwise, if the first character of the data stream is a blank character, then every character before the lam-alef ligature will be shifted to the beginning of the data stream, therefore making available an empty position for the current lam-alef ligature to be deshaped (expanded) into its two constituent characters: lam and alef.
  3. Otherwise, there is no blank character at the beginning and end of the data stream, and the lam-alef ligature cannot be deshaped. If the target CCSID does have the lam-alef ligature, then the lam-alef ligature remains as is; otherwise, the lam-alef ligature is replaced by the target CCSID's SUBstitution character.
Conversely when converting from an Arabic CCSID whose Text Shaping attribute is unshaped to an Arabic CCSID whose Text Shaping attribute is shaped, the source lam and alef characters will be contracted to one ligature character, and a blank character is inserted at the end of the target area data stream.

Procedure

To specify a particular bidirectional CCSID in a non-DRDA environment:

  1. Ensure the DB2BIDI registry variable is set to YES.
  2. Select the CCSID that matches the characteristics of your client, and set DB2CODEPAGE to that value.
  3. If you already have a connection to the database, you must issue a TERMINATE command, and then reconnect for the new setting for DB2CODEPAGE to take effect.

What to do next

For DRDA environments, if the HOST EBCDIC platform also supports these bidirectional CCSIDs, you only need to set the DB2CODEPAGE value. Note that you must not further specify the same CCSID on the BIDI parameter in the PARMS field of the DCS database directory entry for the server database, otherwise an extra bidi layout conversion would occur, and render any Arabic data to be incorrectly reversed. However, if the host platform does not support these CCSIDs, you must also specify a CCSID override for the host database server to which you are connecting. This is accomplished through the use of the BIDI parameter in the PARMS field of the DCS database directory entry for the server database. The override is necessary because, in a DRDA environment, code page conversions and layout transformations are performed by the receiver of data. However, if the host server does not support these bidirectional CCSIDs, it does not perform layout transformation on the data that it receives from the Db2 database system. If you use a CCSID override, the Db2 client performs layout transformation on the outbound data as well.