PreviousNext

Setting the Server's Locale

The server initialization code needs to include a platform-specific routine that sets the locale environment for the server. This step establishes

· The name of the server's local code set, which is the code set that processes on the host will use to encode character data.

· The names of the code sets for which converters exist on the host and consequently, into which processes that run on the host can convert if necessary.

An example of a locale-setting function is the POSIX, XPG3, XPG4 setlocale( ) function, which is defined in locale.h. The server code should call the locale-setting function as the first step in the initialization code, before calling the DCE RPC routines that register the interface and export the binding information.

The locale-setting function also establishes the value for two platform-specific macros that indicate:

· The maximum number of bytes the local code set uses to encode one character.

· The maximum number of bytes that any of the supported code sets on the host will use to encode one character.

On POSIX, XPG3, and XPG4 platforms, these macros are MB_CUR_MAX and MB_LEN_MAX and are defined in stdlib.h and limits.h, respectively. The buffer sizing routines use MB_CUR_MAX when calculating the size of a new buffer to hold converted character data.

Note that all hosts that are members of an "internationalized" DCE cell, that is, a cell that supports internationalized RPC applications, must provide converters that convert between their supported code sets and the ISO 10646 "universal" code set. The DCE RPC functions for character and code set interoperability use the universal code set as the default "intermediate" code set into which a client or server can convert if there are no other compatible code sets between them. Writing the Evaluation Routine discusses intermediate code sets in more detail.