Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
DB Access Module for Sybase User's Guide

2.11 Internationalization and Localization

Sybase supports internationalization through its datatypes nchar, nvarchar, unichar, and univarchar. Datatypes nchar and nvarchar are used for storing characters in the National Language Character Set, and datatypes unichar and univarchar are used for storing data in UTF-16 encoding. For more information, please see the Sybase documentation.

On the client side, Sybase localizes with the help of six operating system environment variables: LC_CTYPE, LC_COLLATE, LC_TIME, LC_MESSAGE, LC_ALL, and LANG. The values of these environment variables change the way Sybase interprets and converts data and produces error messages.

The first four definitions are taken from the Sybase International Developer's Guide for Open Client/Server.

2.11.1 Prerequisites

There are three prerequisites for using internationalization functionality with the DB Access Module for Sybase:

  1. In order to use the Sybase datatypes unichar and univarchar, the Sybase Adaptive Server character set must be set as UTF-8.

  2. When installing the Sybase client, all required locales, localized messages, and character sets must be installed.

  3. Depending on the operating system locale, the values for the environment variables described in Section 2.11 should be specified correctly. These environment variable values and the vendor locale values mentioned in the locales.dat file located in the directory <Sybase home directory>/locales should match. For information on setting up the correct values of the environment variables, please see the Sybase International Developer's Guide for Open Client/Server.

2.11.2 Changing Locales on the Fly

If your application requires more than one locale, you can obtain different database connections with different locale settings using the RWDBSybCtLibEnvironmentHandle APIs, discussed in Section 2.18. With the help of these APIs, you can localize data in different localization formats within the same application.

2.11.3 Data Binding

To fully use the internationalization features supported by Sybase, the Sybase datatypes nchar and nvarchar are bound to the C++ datatype RWDBMBString, and the Sybase datatypes unichar and univarchar are bound to the C++ datatype RWBasicUString.

While sending data to the server, the Sybase Open Client Client-Library internationalizes the contents of the datatypes nchar and nvarchar to convert them to the server encoding, and localizes them while receiving from the server to the client's encoding. Hence, the contents of the nchar and nvarchar datatypes are dependent on the localization settings.

On the other hand, unichar and univarchar datatypes always store UTF-16 encoded data. For this reason, their contents are never internationalized or localized. This data is never converted by the Client-Library while sending or receiving from the server. While binding to the unichar or univarchar datatypes, data must be bound as UTF-16 encoded data; therefore, these server datatypes are bound to the C++ datatype RWBasicUString. RWBasicUString is a datatype in the Essential Tools Module designed to encapsulate UTF-16 encoded data. The unichar and univarchar datatypes can also be bound to the C++ datatype RWUString provided in the Internationalization Module.

Please see Section 2.3, "Datatypes," for more information on data binding.

2.11.4 Limitations

Internationalization functionality for the DB Access Module for Sybase carries the following limitations:

  1. The Sybase datatypes unichar and univarchar are available only on Sybase Adaptive server version 12.5 or higher with Sybase Open Client 12.5 or higher.

  2. As per Sybase documentation, in order for unichar and univarchar datatypes to function correctly, Sybase Adaptive Server must use the character set of UTF-8.

  3. Currently, the DB Access Module for Sybase does not support Unicode logins, passwords, or metadata.

2.11.5 RWWString

Sybase does not differentiate between multibyte and wide character strings while inserting or retrieving data from the server. During input binding, RWWString data are converted to RWDBMBString data before binding. In output binding, the data is received as an MBString and then converted to a WString, if required.

RWWStrings should not be used for binding with Sybase datatypes unichar or univarchar. Even if they contain UTF-16 encoded data, RWWString data is converted to RWDBMBString before binding and hence will no longer bind UTF-16 encoded data.

2.11.6 Date Formats

Date expressions are loaded into the database and extracted from the database in a locale neutral manner. The DB Interface Module properly formats instances of RWDateTime, RWDate, and RWDBDateTime automatically. The application programmer is responsible for formatting these types outside the scope of DB Interface Module API calls.



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.