Universal encoding is only one component of globalized software. A second component involves locale awareness. That is, the application must observe the language rules and cultural conventions that the user has selected. Representing such things as the date, time, currency symbols, numerals, addresses, andtelephone numbers in a format that matches the user's language, culture, and country standards is an essential task.

Locale variables define various system components that deal with international support. However, of all the variables available on Windows, only the user locale, the location, the browser language setting, and the thread locale deal with locale awareness in applications.

Within the Win32 programming environment, NLS APIs provide the right tools to eliminate any locale-specific assumptions from your application, allowing you to represent data in the formatting that corresponds to the currently selected user locale identified by a locale ID (LCID). The .NET Framework took a new approach to the definition of locale identification and readjusted the misnaming introduced by NLS APIs with its introduction of culture information, represented by the CultureInfo class from theSystem.Globalization namespace. This class contains culture-specific information, such as the language, country or region, calendar, and cultural conventions. This class also provides the information required for performing culture-specific operations, such as casing, formatting dates and numbers, and comparing strings.

Since all APIs and functions that allow locale-specific formatting take as an argument the locale ID or the culture name for which this formatting should be performed, the first step in writing locale-aware software is to retrieve the proper locale.

String sorting and comparison is another important part of the process. Even within languages based on the Latin script, there are different composition and sorting rules. Thus, do not rely on code points to do proper sorting and string comparison. The Win32 functions lstrcmp and lstrcmpi compare two character strings in a case-sensitive or case-insensitive manner, respectively, following the sorting rules and standards that are defined for the currently selected user locale. In the .NET Framework, the CompareInfo class provides a set of methods you can use to perform culture-sensitive string comparisons.

Finally, language-specific operations of console applications can follow the locale settings of the system. This will guarantee locale-authentic formatting of numbers, date, time, currency values, and collation (sorting) operations. Locale support is available for character-mode applications through both CRT and Win32. However, these mechanisms should never be mixed. For new Windows applications, Win32 mechanisms are preferred over those in CRT with regard to world-ready code.

Microsoft Corporation - Developing International Software
Developing International Software
ISBN: 0735615837
EAN: 2147483647
Year: 2003
Pages: 198

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: