Skip to main content

Globalization Step-by-Step

World-Ready Guide - Units of Measurement

 

*

 

Overview and Description

Throughout the world things are measured using different units and scales. The most popular one used is the metric system (meters, liters, grams, etc). Where as the US still uses the imperial system (feet, inches, pounds, etc). The kind of measurements referred to are for things like:

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

Thus you need to make sure that if you deal with measurements, you can display them in different systems. Also, make sure it is clear to the use on what system is currently being display. Remember a Mars probe was lost because it's guidance system was developed for one system and the scientists using it thought it was the other system.

Top of pageTop of page

Units of Measurement in Win32

Although you need to do your own conversions between the metric and US systems, Win32 NLS APIs can help you detect which system of measurement is used for a given locale.

The system of measurement can be obtain from GetLocaleInfo API with LCType flag set to LOCALE_IMEASURE. The returned value is 0 if the metric system (Système International d'unités, or S.I.) is used, and 1 if the U.S. system is used. The maximum number of characters allowed for this string is two.

DWORD dwMSys; 
GetLocaleInfo(LOCALE_USER_DEFAULT,     // locale identifier (current user locale)
LOCALE_IMEASURE|LOCALE_RETURN_NUMBER,  // information type (measurement system)
&dwMSys,                               // retuned value
sizeof (DWORD));

Top of pageTop of page

Units of Measurement in .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.

Top of pageTop of page

References

You can find the default system of measurement for each locale in the master list of locales.


 

Top of pageTop of page Previous11 of 11