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

U_STABLE int32_t U_EXPORT2 uloc_getCountry ( const char *  localeID,
char *  country,
int32_t  countryCapacity,
UErrorCode err 
)

Gets the country code for the specified locale.

Parameters:
localeID the locale to get the country code with
country the country code for localeID
countryCapacity the size of the country buffer to store the country code with
err error information if retrieving the country code failed
Returns:
the actual buffer size needed for the country code. If it's greater than countryCapacity, the returned country code will be truncated. ICU 2.0

Definition at line 1873 of file uloc.c.

References NULL, and U_FAILURE.

{
    int32_t i=0;

    if(err==NULL || U_FAILURE(*err)) {
        return 0;
    }

    if(localeID==NULL) {
        localeID=uloc_getDefault();
    }

    /* Skip the language */
    ulocimp_getLanguage(localeID, NULL, 0, &localeID);
    if(_isIDSeparator(*localeID)) {
        const char *scriptID;
        /* Skip the script if available */
        ulocimp_getScript(localeID+1, NULL, 0, &scriptID);
        if(scriptID != localeID+1) {
            /* Found optional script */
            localeID = scriptID;
        }
        if(_isIDSeparator(*localeID)) {
            i=ulocimp_getCountry(localeID+1, country, countryCapacity, NULL);
        }
    }
    return u_terminateChars(country, countryCapacity, i, err);
}


Generated by  Doxygen 1.6.0   Back to index