static PyObject *t_localedata_getMeasurementSystem(t_localedata *self) { UMeasurementSystem ms; STATUS_CALL(ms = ulocdata_getMeasurementSystem(self->locale_id, &status)); return PyInt_FromLong(ms); }
BMeasurementKind BFormattingConventions::MeasurementKind() const { UErrorCode error = U_ZERO_ERROR; switch (ulocdata_getMeasurementSystem(ID(), &error)) { case UMS_US: return B_US; case UMS_SI: default: return B_METRIC; } }
/* Function: GetMeasurementSystem Obtains the measurement system for the local, determining if US or metric. Returns 1 for US, 0 otherwise. */ UErrorCode GetMeasurementSystem(const char* locale, int32_t* value) { UErrorCode status = U_ZERO_ERROR; UMeasurementSystem measurementSystem = ulocdata_getMeasurementSystem(locale, &status); if (U_SUCCESS(status)) { *value = (measurementSystem == UMeasurementSystem::UMS_US) ? 1 : 0; } return status; }
static bool __CFLocaleCopyUsesMetric(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context) { bool us = false; // Default is Metric bool done = false; if (!done) { char localeID[ULOC_FULLNAME_CAPACITY+ULOC_KEYWORD_AND_VALUES_CAPACITY]; if (CFStringGetCString(locale->_identifier, localeID, sizeof(localeID)/sizeof(char), kCFStringEncodingASCII)) { UErrorCode icuStatus = U_ZERO_ERROR; UMeasurementSystem ms = UMS_SI; ms = ulocdata_getMeasurementSystem(localeID, &icuStatus); if (U_SUCCESS(icuStatus)) { us = (ms == UMS_US); done = true; } } } if (!done) us = false; *cf = us ? CFRetain(kCFBooleanFalse) : CFRetain(kCFBooleanTrue); return true; }