Logo Search packages:      
Sourcecode: icu version File versions  Download package

NumberingSystem *U_EXPORT2 NumberingSystem::createInstance ( const Locale inLocale,
UErrorCode status 
) [static]

Create the default numbering system associated with the specified locale.

Parameters:
inLocale The given locale.
status ICU status ICU 4.2

Definition at line 93 of file numsys.cpp.

References createInstanceByName(), Locale::getKeywordValue(), Locale::getName(), NULL, NumberingSystem(), U_FAILURE, U_USING_FALLBACK_WARNING, and ULOC_KEYWORDS_CAPACITY.

Referenced by createInstance(), createInstanceByName(), DecimalFormatSymbols::initialize(), NumberFormat::makeInstance(), and NumberFormatTest::TestNumberingSystems().

                                                                           {

    char buffer[ULOC_KEYWORDS_CAPACITY];
    int32_t count = inLocale.getKeywordValue("numbers",buffer, sizeof(buffer),status);
    if ( count > 0 ) { // @numbers keyword was specified in the locale
        buffer[count] = '\0'; // Make sure it is null terminated.
        return NumberingSystem::createInstanceByName(buffer,status);
    } else { // Find the default numbering system for this locale.
        LocalUResourceBundlePointer resource(ures_open(NULL, inLocale.getName(), &status));
        if (U_FAILURE(status)) {
            status = U_USING_FALLBACK_WARNING;
            NumberingSystem *ns = new NumberingSystem();
            return ns;
        } 
        const UChar *defaultNSName =
            ures_getStringByKeyWithFallback(resource.getAlias(), gDefaultNumberingSystem, &count, &status);
        if ( count > 0 && count < ULOC_KEYWORDS_CAPACITY ) { // Default numbering system found
           u_UCharsToChars(defaultNSName,buffer,count); 
           buffer[count] = '\0'; // Make sure it is null terminated.
           return NumberingSystem::createInstanceByName(buffer,status);
        } else {
            status = U_USING_FALLBACK_WARNING;
            NumberingSystem *ns = new NumberingSystem();
            return ns;
        }
        
    }
}


Generated by  Doxygen 1.6.0   Back to index