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

U_STABLE UEnumeration* U_EXPORT2 uloc_openKeywords ( const char *  localeID,
UErrorCode status 
)

Gets an enumeration of keywords for the specified locale. Enumeration must get disposed of by the client using uenum_close function.

Parameters:
localeIDthe locale to get the variant code with
statuserror information if retrieving the keywords failed
Returns:
enumeration of keywords or NULL if there are no keywords. ICU 2.8

Definition at line 1511 of file uloc.c.

References FALSE, NULL, and U_FAILURE.

{
    int32_t i=0;
    char keywords[256];
    int32_t keywordsCapacity = 256;
    if(status==NULL || U_FAILURE(*status)) {
        return 0;
    }
    
    if(localeID==NULL) {
        localeID=uloc_getDefault();
    }

    /* Skip the language */
    _getLanguage(localeID, NULL, 0, &localeID);
    if(_isIDSeparator(*localeID)) {
        const char *scriptID;
        /* Skip the script if available */
        _getScript(localeID+1, NULL, 0, &scriptID);
        if(scriptID != localeID+1) {
            /* Found optional script */
            localeID = scriptID;
        }
        /* Skip the Country */
        if (_isIDSeparator(*localeID)) {
            _getCountry(localeID+1, NULL, 0, &localeID);
            if(_isIDSeparator(*localeID)) {
                _getVariant(localeID+1, *localeID, NULL, 0);
            }
        }
    }

    /* keywords are located after '@' */
    if((localeID = locale_getKeywordsStart(localeID)) != NULL) {
        i=locale_getKeywords(localeID+1, '@', keywords, keywordsCapacity, NULL, 0, NULL, FALSE, status);
    }

    if(i) {
        return uloc_openKeywordList(keywords, i, status);
    } else {
        return NULL;
    }
}

Generated by  Doxygen 1.6.0   Back to index