Additional support for localized clients

An Open Server application needs to take additional steps to support localized clients under the following circumstances:


Localizing CS-Library messages for clients

If an Open Server application calls a CS-Library routine with its own context structure as a parameter, any error messages that CS-Library generates as the result of the call will be in the Open Server application’s language and character set.

For example, if the context parameter for a cs_convert call indicates us_english/iso_1, CS-Library will generate a us_english/iso_1 message if the cs_convert call fails.

NoteIf a CS-Library routine takes a CS_LOCALE structure as a parameter, the localization values in this structure will override the localization values in the context parameter.

Getting CS-Library messages in the Open Server application’s language and character set is acceptable only if the Open Server application logs the CS-Library messages or otherwise keeps them to itself.

However, if an Open Server application will be passing CS-Library error messages back to a client, it needs to ensure that CS-Library generates messages in the client’s language and the Open Server application’s character set.

The messages need to be in the client’s language for the client to understand them.

The messages need to be in the Open Server application’s character set for two reasons:

An application can ensure that messages are generated in the correct language and character set by setting up a properly localized CS_CONTEXT structure for each client thread and then using these CS_CONTEXT structures when calling CS-Library routines on behalf of clients.


Localizing a CS_CONTEXT structure for a client thread

Table 3-6 illustrates how to localize a CS_CONTEXT structure for a client thread:

Table 3-6: Localizing a CS_CONTEXT structure for a client thread

Step

Application step

Purpose

Details

1

Call cs_ctx_alloc.

Allocate a CS_CONTEXT structure for the client thread.

The context structure is allocated with initial localization values.

2

Call cs_loc_alloc.

Allocate a new CS_LOCALE structure.

This call copies the parent context’s current localization information into the new CS_LOCALE structure.

3

Call srv_thread_props(GET) with property as SRV_T_LOCALE.

Copy the client thread’s existing localization values into the new CS_LOCALE structure.

4

Call cs_locale with type as CS_SYB_CHARSET.

Replace the client thread’s character set information in the new CS_LOCALE structure with the Open Server application’s character set information.

5

Call cs_config with property as CS_LOC_PROP.

Customize the context structure.

This call copies localization information from the CS_LOCALE structure into the CS_CONTEXT structure.

6

Optionally, call cs_loc_drop.

Deallocate the CS_LOCALE structure.

An application can reuse the CS_LOCALE structure before deallocating it.

If necessary, the application can call cs_locale to change the localization values in the structure before reusing it.


Creating localized connections for Open Server gateways

If an Open Server application is acting as a gateway, it needs to ensure that a connection to a remote server uses the client’s language and the Open Server’s character set.

NoteThe Open Server’s character set does not need to be the same as the remote server’s character set, but it must be one that the remote server is capable of converting to its own.

Adaptive Server can convert between any two Western European character sets and between any two Japanese character sets, but it cannot convert a Western European character set to a Japanese one (and vice versa). For example, Adaptive Server can convert between ISO 8859-1 and CP850, because both of these character sets are in the Western European language group, but Adaptive Server cannot convert between ISO 8859-1, which is Western European, and CP 1250, which is Eastern European. When Adaptive Server is converting between character sets in different language groups, non-ASCII characters may be lost.

The simplest way for an application to do this is to set up a properly localized CS_CONTEXT structure for each client thread and then allocate remote connections for the client thread within the localized context.

For more information, see “Localizing a CS_CONTEXT structure for a client thread”.

For information on how to allocate a connection, see the Open Client Client-Library/C Reference Manual.