You are on page 1of 2

=========================================================================== International API =========================================================================== Borland C++ provides support for international program development.

Currently, support is provided for the Great Britain and United States English, French, and German locales. Future releases of Borland C++ will increase the number of locales supported. The LOCALE.BLL file is installed in BC45\BIN directory. Support for these locales is contained in the LOCALE.BLL library. By default, the "C" locale is in effect. However, a call to setlocale dynamically links the LOCALE.BLL library to your program. A localespecific module is enabled by a call to setlocale. The call will also specify which character set to use with the locale. (Character set is sometimes referred to as "code page" or "code set.") You can query the locale settings by using localeconv and setlocale functions. See the Library Reference, Chapter 3, for a description of these functions. If the call to setlocale can be resolved, several character-handling functions change their behavior. Because Borland C++ 4.5 international API currently supports only 8-bit characters (thereby enabling recognition of as many as 256 characters), only single-byte character-handling functions are affected. The list of affected functions is in the Library Reference, Chapter 1. In your code, you must #define _ _USELOCALES_ _to have the locale-sensitive functions available. Otherwise, only the "C" locale macros will be used. The international ======================================================= API sample program To illustrate the effects of selecting different locales, Borland C++ provides a sample program. The sample program (named INTLDEMO.EXE) is an ObjectWindows application. All source code and a project file for the sample are provided. The sample program INTLDEMO (in BC45\EXAMPLES\WINDOWS\INTLDEMO) demonstrates how the setlocale function can produce an "internationally aware" Windows application. You can switch the interface language at run time between English, French, and German. 1

INTLDEMO displays all of the Windows ANSI character set (also referred to as the WIN 1252 character set) in a 16-by-16 character grid. A number of characters are highlighted according to the selections under the "Locale" and the "Classification" menus. When you execute INTLDEMO, the screen shows the default "C" locale, and the default classification is isalpha. The highlighted characters are therefore the characters A to Z and a to z. By selecting another locale (for example, French) the accented versions of the characters (for example ) are also highlighted. Various combinations of locale and classification can be illustrated by selecting the appropriate menu items. The results of calling the localeconv function for the current locale are illustrated by selecting "Conventions|Show". For example, with the French locale selected, the international currency symbol becomes FRF and the currency symbol becomes F. Note that this window can remain open while either the language or locale is changed and the values are updated accordingly. The "File|List" menu produces a dialog box that demonstrates the effects of the locale on collation sequences and on date and time functions. The files in the current directory are shown sorted according to the current locale, and with date and times displayed according to the conventions and in the language of the selected locale. File names can be switched between upper/lower case to demonstrate the effects of the toupper and tolower functions in the current locale. The dialog also illustrates the effects of the BWCCIntlInit function on the Ok, Cancel and Help buttons of the dialog. Any file can be selected to be viewed and its contents similarly sorted according to the current locale collation sequence. The "Language" menu allows the language of the UI to be changed "on the fly." This feature uses ObjectWindow's ability to associate windows interface elements to a module, in this case a .DLL that contains the resources in a particular language. When the language is changed, a new language .DLL is loaded and the interface elements are reloaded from that .DLL. Note that the date and times in the File List dialog are not affected by the change in language, but by the choice of locale. The 'Classification' menu shows a list of the localesensitive isxxx() functions. Selecting one of these items will cause the characters that return true for this function in the current locale to be highlighted in the main window.