Units of Measure

Throughout the world things are measured using different units and scales. The most popular method of measurement used is the metric system (meters, liters, grams, and so on). (The most current version of the metric system is known as "Système Internationale d'Unités," or "S.I.") The United States, on the other hand, uses the U.S. Customary System3 (feet, inches, pounds, and so on). The kind of measurements referred to are for things like the following:

  • Lengths
  • Weights
  • Area
  • Volume
  • Temperatures
  • Paper sizes
  • Angle notation

Thus you need to make sure that if you deal with measurements, you can display them in different measurement systems. Also, make sure it is clear to the user which system is currently being displayed. Recall the unfortunate incident in September 1999 involving a Mars probe that strayed off course, partly because of controllers' faulty data conversions from U.S. Customary to metric units of measurement.

Units of Measure in Win32

Although you need to do your own conversions between the metric and U.S. systems, Win32 NLS APIs can help you detect which system of measurement is used for a given locale. The system of measurement can be obtained from the GetLocaleInfo API with the LCType flag set to LOCALE_IMEASURE. The returned value is 0 if the metric system is used, and 1 if the U.S. Customary System is used. The maximum number of characters allowed for this string is two.

Units of Measure in the .NET Framework

The RegionInfo class from the System.Globalization namespace contains information about the country or region. In contrast to CultureInfo, RegionInfo does not represent preferences of the user and does not depend on the user's language or culture. A good example of this category of information is the IsMetric property of RegionInfo that gets a Boolean value indicating whether the country or region uses the metric system for measurements.

Until now, this chapter has dealt with locale awareness in terms of Win32 applications, Web pages, and the .NET Framework. The final major area to consider is how to handle language-specific operations with console applications. The final sections of this chapter, therefore, will concentrate on this task.



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

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net