Previous Table of Contents Next


13.10.4 Example of Generic Environment Mapping


   This section shows how char, wchar, string, and wchar can be mapped to the generic C/C++ macros of the Windows environment. This is merely to illustrate one possibility. This section is not normative and is applicable only in generic environments. See Section 13.10.3, “Mapping to Generic Character Environments? on page 13-48.

   13.10.4.1 Generic Mappings

   Char and string are mapped to C/C++ char and char* as per the standard C/C++ mappings. wchar is mapped to the TCHAR macro which expands to either char or wchar_t depending on whether _UNICODE is defined. wstring is mapped to pointers to TCHAR as well as to the string class CORBA::Wstring_var. Literal strings in IDL are mapped to the _TEXT macro as in _TEXT(<literal>).

   13.10.4.2 Interoperation and Generic Mappings

   We now illustrate how the interoperation works with the above generic mapping. Consider an IDL interface operation with a wstring parameter, a client for the operation which is compiled and run on a Windows 95 machine, and a server for the operation which is compiled and run on a Windows NT machine. Assume that the locale (and/or the environment variables for CNCS for wchar representation) on the Windows 95 client indicates the client’s native code set to be SJIS, and that the corresponding server’s native code set is Unicode. The code set negotiation in this case will probably choose Unicode as the TCS-W.

   Both the client and server sides will be compiled with _UNICODE defined. The IDL type wstring will be represented as a string of wchar_t on the client. However, since the client’s locale or environment indicates that the CNCS for wide characters is SJIS, the client side ORB will get the wstring parameter encoded as a SJIS multi-byte string (since that is the client’s native code set), which it will then convert to Unicode before transmitting to the server. On the server side the ORB has no conversions to do since the TCS-W matches the server’s native code set for wide characters.

   We therefore notice that the code set conversion framework handles the necessary translations between byte-oriented and wide forms.