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

U_STABLE int32_t U_EXPORT2 uloc_getVariant ( const char *  localeID,
char *  variant,
int32_t  variantCapacity,
UErrorCode err 

Gets the variant code for the specified locale.

localeIDthe locale to get the variant code with
variantthe variant code for localeID
variantCapacitythe size of the variant buffer to store the variant code with
errerror information if retrieving the variant code failed
the actual buffer size needed for the variant code. If it's greater than variantCapacity, the returned variant code will be truncated. ICU 2.0

Definition at line 1906 of file uloc.c.

References NULL, and U_FAILURE.

    int32_t i=0;
    if(err==NULL || U_FAILURE(*err)) {
        return 0;
    if(localeID==NULL) {
    /* 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)) {
                i=_getVariant(localeID+1, *localeID, variant, variantCapacity);
    /* removed by weiv. We don't want to handle POSIX variants anymore. Use canonicalization function */
    /* if we do not have a variant tag yet then try a POSIX variant after '@' */
    if(!haveVariant && (localeID=uprv_strrchr(localeID, '@'))!=NULL) {
        i=_getVariant(localeID+1, '@', variant, variantCapacity);
    return u_terminateChars(variant, variantCapacity, i, err);

Generated by  Doxygen 1.6.0   Back to index