When a client connects to an Open Server application, Open Server automatically creates a CS_LOCALE structure reflecting the client’s language and character set. (The client’s collating sequence is NOT included in the CS_LOCALE structure: Collating sequence information is not transmitted to the server at login time.)
For example, when a french/cp850 client logs into a us_english/iso_1 Open Server application, the Open Server application creates a french/cp850 CS_LOCALE structure. The Open Server application uses this CS_LOCALE structure to set up character set conversion routines for the client thread.
The information in this CS_LOCALE structure
is available to Open Server programmers, who can call srv_thread_props to
copy the information into a newly allocated CS_LOCALE structure.
After logging in, 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 one of 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 processes 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 processes the request inside a SRV_OPTION event handler.
Table 3-7 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. |
Overwrites the CS_LOCALE structure with the requested language or character set. |
For more information about this process, see “The cs_locale routine”. |
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. |