case UAMEASUNIT_AREA_SQUARE_CENTIMETER: munit = MeasureUnit::createSquareCentimeter(*status); break;
case UAMEASUNIT_AREA_SQUARE_INCH: munit = MeasureUnit::createSquareInch(*status); break;
case UAMEASUNIT_AREA_SQUARE_YARD: munit = MeasureUnit::createSquareYard(*status); break;
+ case UAMEASUNIT_AREA_DUNAM: munit = MeasureUnit::createDunam(*status); break;
case UAMEASUNIT_DURATION_YEAR: munit = MeasureUnit::createYear(*status); break;
case UAMEASUNIT_DURATION_MONTH: munit = MeasureUnit::createMonth(*status); break;
case UAMEASUNIT_DURATION_MICROSECOND: munit = MeasureUnit::createMicrosecond(*status); break;
case UAMEASUNIT_DURATION_NANOSECOND: munit = MeasureUnit::createNanosecond(*status); break;
case UAMEASUNIT_DURATION_CENTURY: munit = MeasureUnit::createCentury(*status); break;
+ case UAMEASUNIT_DURATION_YEAR_PERSON: munit = MeasureUnit::createYearPerson(*status); break;
+ case UAMEASUNIT_DURATION_MONTH_PERSON: munit = MeasureUnit::createMonthPerson(*status); break;
+ case UAMEASUNIT_DURATION_WEEK_PERSON: munit = MeasureUnit::createWeekPerson(*status); break;
+ case UAMEASUNIT_DURATION_DAY_PERSON: munit = MeasureUnit::createDayPerson(*status); break;
case UAMEASUNIT_LENGTH_METER: munit = MeasureUnit::createMeter(*status); break;
case UAMEASUNIT_LENGTH_CENTIMETER: munit = MeasureUnit::createCentimeter(*status); break;
case UAMEASUNIT_LENGTH_ASTRONOMICAL_UNIT: munit = MeasureUnit::createAstronomicalUnit(*status); break;
case UAMEASUNIT_LENGTH_PARSEC: munit = MeasureUnit::createParsec(*status); break;
case UAMEASUNIT_LENGTH_MILE_SCANDINAVIAN: munit = MeasureUnit::createMileScandinavian(*status); break;
+ case UAMEASUNIT_LENGTH_POINT: munit = MeasureUnit::createPoint(*status); break;
+ case UAMEASUNIT_LENGTH_SOLAR_RADIUS: munit = MeasureUnit::createSolarRadius(*status); break;
case UAMEASUNIT_MASS_GRAM: munit = MeasureUnit::createGram(*status); break;
case UAMEASUNIT_MASS_KILOGRAM: munit = MeasureUnit::createKilogram(*status); break;
case UAMEASUNIT_MASS_TON: munit = MeasureUnit::createTon(*status); break;
case UAMEASUNIT_MASS_CARAT: munit = MeasureUnit::createCarat(*status); break;
case UAMEASUNIT_MASS_OUNCE_TROY: munit = MeasureUnit::createOunceTroy(*status); break;
+ case UAMEASUNIT_MASS_DALTON: munit = MeasureUnit::createDalton(*status); break;
+ case UAMEASUNIT_MASS_EARTH_MASS: munit = MeasureUnit::createEarthMass(*status); break;
+ case UAMEASUNIT_MASS_SOLAR_MASS: munit = MeasureUnit::createSolarMass(*status); break;
case UAMEASUNIT_POWER_WATT: munit = MeasureUnit::createWatt(*status); break;
case UAMEASUNIT_POWER_KILOWATT: munit = MeasureUnit::createKilowatt(*status); break;
case UAMEASUNIT_PRESSURE_HECTOPASCAL: munit = MeasureUnit::createHectopascal(*status); break;
case UAMEASUNIT_PRESSURE_INCH_HG: munit = MeasureUnit::createInchHg(*status); break;
case UAMEASUNIT_PRESSURE_MILLIBAR: munit = MeasureUnit::createMillibar(*status); break;
- case UAMEASUNIT_PRESSURE_MILLIMETER_OF_MERCURY: munit = MeasureUnit::createMillimeterOfMercury(*status); break;
+ case UAMEASUNIT_PRESSURE_MILLIMETER_OF_MERCURY: munit = MeasureUnit::createMillimeterOfMercury(*status); break;
case UAMEASUNIT_PRESSURE_POUND_PER_SQUARE_INCH: munit = MeasureUnit::createPoundPerSquareInch(*status); break;
+ case UAMEASUNIT_PRESSURE_ATMOSPHERE: munit = MeasureUnit::createAtmosphere(*status); break;
+ case UAMEASUNIT_PRESSURE_KILOPASCAL: munit = MeasureUnit::createKilopascal(*status); break;
+ case UAMEASUNIT_PRESSURE_MEGAPASCAL: munit = MeasureUnit::createMegapascal(*status); break;
case UAMEASUNIT_SPEED_METER_PER_SECOND: munit = MeasureUnit::createMeterPerSecond(*status); break;
case UAMEASUNIT_SPEED_KILOMETER_PER_HOUR: munit = MeasureUnit::createKilometerPerHour(*status); break;
case UAMEASUNIT_VOLUME_CUP_METRIC: munit = MeasureUnit::createCupMetric(*status); break;
case UAMEASUNIT_VOLUME_PINT_METRIC: munit = MeasureUnit::createPintMetric(*status); break;
case UAMEASUNIT_VOLUME_GALLON_IMPERIAL: munit = MeasureUnit::createGallonImperial(*status); break;
+ case UAMEASUNIT_VOLUME_FLUID_OUNCE_IMPERIAL: munit = MeasureUnit::createFluidOunceImperial(*status); break;
+ case UAMEASUNIT_VOLUME_BARREL: munit = MeasureUnit::createBarrel(*status); break;
case UAMEASUNIT_ENERGY_JOULE: munit = MeasureUnit::createJoule(*status); break;
case UAMEASUNIT_ENERGY_KILOJOULE: munit = MeasureUnit::createKilojoule(*status); break;
case UAMEASUNIT_ENERGY_KILOCALORIE: munit = MeasureUnit::createKilocalorie(*status); break;
case UAMEASUNIT_ENERGY_FOODCALORIE: munit = MeasureUnit::createFoodcalorie(*status); break;
case UAMEASUNIT_ENERGY_KILOWATT_HOUR: munit = MeasureUnit::createKilowattHour(*status); break;
+ case UAMEASUNIT_ENERGY_ELECTRONVOLT: munit = MeasureUnit::createElectronvolt(*status); break;
+ case UAMEASUNIT_ENERGY_BRITISH_THERMAL_UNIT: munit = MeasureUnit::createBritishThermalUnit(*status); break;
case UAMEASUNIT_CONSUMPTION_LITER_PER_KILOMETER: munit = MeasureUnit::createLiterPerKilometer(*status); break;
case UAMEASUNIT_CONSUMPTION_MILE_PER_GALLON: munit = MeasureUnit::createMilePerGallon(*status); break;
case UAMEASUNIT_DIGITAL_MEGABYTE: munit = MeasureUnit::createMegabyte(*status); break;
case UAMEASUNIT_DIGITAL_TERABIT: munit = MeasureUnit::createTerabit(*status); break;
case UAMEASUNIT_DIGITAL_TERABYTE: munit = MeasureUnit::createTerabyte(*status); break;
+ case UAMEASUNIT_DIGITAL_PETABYTE: munit = MeasureUnit::createPetabyte(*status); break;
case UAMEASUNIT_ELECTRIC_AMPERE: munit = MeasureUnit::createAmpere(*status); break;
case UAMEASUNIT_ELECTRIC_MILLIAMPERE: munit = MeasureUnit::createMilliampere(*status); break;
case UAMEASUNIT_FREQUENCY_GIGAHERTZ: munit = MeasureUnit::createGigahertz(*status); break;
case UAMEASUNIT_LIGHT_LUX: munit = MeasureUnit::createLux(*status); break;
+ case UAMEASUNIT_LIGHT_SOLAR_LUMINOSITY: munit = MeasureUnit::createSolarLuminosity(*status); break;
case UAMEASUNIT_CONCENTRATION_KARAT: munit = MeasureUnit::createKarat(*status); break;
case UAMEASUNIT_CONCENTRATION_MILLIGRAM_PER_DECILITER: munit = MeasureUnit::createMilligramPerDeciliter(*status); break;
case UAMEASUNIT_CONCENTRATION_MILLIMOLE_PER_LITER: munit = MeasureUnit::createMillimolePerLiter(*status); break;
case UAMEASUNIT_CONCENTRATION_PART_PER_MILLION: munit = MeasureUnit::createPartPerMillion(*status); break;
+ case UAMEASUNIT_CONCENTRATION_PERCENT: munit = MeasureUnit::createPercent(*status); break;
+ case UAMEASUNIT_CONCENTRATION_PERMILLE: munit = MeasureUnit::createPermille(*status); break;
+ case UAMEASUNIT_CONCENTRATION_PERMYRIAD: munit = MeasureUnit::createPermyriad(*status); break;
+ case UAMEASUNIT_CONCENTRATION_MOLE: munit = MeasureUnit::createMole(*status); break;
+
+ case UAMEASUNIT_FORCE_NEWTON: munit = MeasureUnit::createNewton(*status); break;
+ case UAMEASUNIT_FORCE_POUND_FORCE: munit = MeasureUnit::createPoundForce(*status); break;
+
+ case UAMEASUNIT_TORQUE_NEWTON_METER: munit = MeasureUnit::createNewtonMeter(*status); break;
+ case UAMEASUNIT_TORQUE_POUND_FOOT: munit = MeasureUnit::createPoundFoot(*status); break;
default: *status = U_ILLEGAL_ARGUMENT_ERROR; break;
}
};
enum { kKeyToUnitsCount = UPRV_LENGTHOF(keyToUnits) };
-enum { kCombinedKeyMax = 64 };
+enum { kCombinedKeyMax = 64, kKeyValueMax = 15 };
static int compareKeyToUnits(const void* searchKey, const void* tableEntry) {
return uprv_strncmp(((const KeyToUnits*)searchKey)->key, ((const KeyToUnits*)tableEntry)->key, kCombinedKeyMax);
// Get region to use
char region[ULOC_COUNTRY_CAPACITY];
- (void)ulocimp_getRegionForSupplementalData(locale, TRUE, region, sizeof(region), status);
- if (U_FAILURE(*status)) {
- return 0;
+ UErrorCode localStatus;
+ UBool usedOverride = FALSE;
+ // First check for ms overrides, except in certain categories
+ if (uprv_strcmp(category, "concentr") != 0 && uprv_strcmp(category, "duration") != 0) {
+ char msValue[kKeyValueMax + 1];
+ localStatus = U_ZERO_ERROR;
+ int32_t msValueLen = uloc_getKeywordValue(locale, "ms", msValue, kKeyValueMax, &localStatus);
+ if (U_SUCCESS(localStatus) && msValueLen> 2) {
+ msValue[kKeyValueMax] = 0; // ensure termination
+ if (uprv_strcmp(msValue, "metric") == 0) {
+ uprv_strcpy(region, "001");
+ usedOverride = TRUE;
+ } else if (uprv_strcmp(msValue, "ussystem") == 0) {
+ uprv_strcpy(region, "US");
+ usedOverride = TRUE;
+ } else if (uprv_strcmp(msValue, "uksystem") == 0) {
+ uprv_strcpy(region, "GB");
+ usedOverride = TRUE;
+ }
+ }
+ }
+ if (!usedOverride) {
+ (void)ulocimp_getRegionForSupplementalData(locale, TRUE, region, sizeof(region), status);
+ if (U_FAILURE(*status)) {
+ return 0;
+ }
}
UResourceBundle *unitb = NULL;
- UErrorCode localStatus = U_ZERO_ERROR;
+ localStatus = U_ZERO_ERROR;
int32_t retval = 0;
UResourceBundle *regb = ures_getByKey(prefb, region, NULL, &localStatus);
if (U_SUCCESS(localStatus)) {