When a client connects to an Open Server, it specifies a language and character set in the login record. Open Server uses this information to set up a CS_LOCALE and character set conversion routines for the client thread.
Open Server handles this automatically; an Open Server application does not need to take any steps to handle localized clients at login time.
However, after logging in, clients can change their language and character set. If a client sends a request to change its language or character set, the Open Server application must make the requested changes in the client thread’s CS_LOCALE structure.
A client can request a change of language or character set in two ways:
Using a language-based option command sent with ct_command. This type of command triggers a SRV_LANGUAGE event, so the Open Server application will process the request inside a SRV_LANGUAGE event handler.
Using an option command sent with ct_options. This type of command triggers a SRV_OPTION event, so the Open Server application will process the request inside a SRV_OPTION event handler.
In both cases, the Open Server application responds by:
Setting up a CS_LOCALE structure with the new language or character set
Calling the srv_thread_props routine with property set to SRV_T_LOCALE to change the language or character set for the thread connection
Table 2-19 describes how to change the language or character set for a client thread:
Step |
Application step |
Purpose |
Details |
---|---|---|---|
1 |
Call cs_loc_alloc. |
Allocate a CS_LOCALE structure. |
This call copies the Open Server application context’s current localization information into the new CS_LOCALE structure. |
2 |
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. |
|
3 |
Call cs_locale. |
Overwrite the CS_LOCALE structure with the requested language or character set. |
For more information about this process, see “Localizing a CS_CONTEXT structure”. |
4 |
Call srv_thread_props(SET) with property as SRV_T_LOCALE. |
Set up the client thread with the new language or character set. |
|
5 |
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. |