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

U_STABLE int32_t U_EXPORT2 uloc_minimizeSubtags ( const char *  localeID,
char *  minimizedLocaleID,
int32_t  minimizedLocaleIDCapacity,
UErrorCode err 
)

Minimize the subtags for a provided locale ID, per the algorithm described in the following CLDR technical report:

http://www.unicode.org/reports/tr35/#Likely_Subtags

If localeID is already in the minimal form, or there is no data available for minimization, it will be copied to the output buffer. Since the minimization algorithm relies on proper maximization, see the comments for uloc_addLikelySubtags for reasons why there might not be any data.

Examples:

"en_Latn_US" minimizes to "en"

"de_Latn_US" minimizes to "de"

"sr_Cyrl_RS" minimizes to "sr"

"zh_Hant_TW" minimizes to "zh_TW" (The region is preferred to the script, and minimizing to "zh" would imply "zh_Hans_CN".)

Parameters:
localeID The locale to minimize
minimizedLocaleID The minimized locale
minimizedLocaleIDCapacity The capacity of the minimizedLocaleID buffer
err Error information if minimizing the locale failed. If the length of the localeID and the null-terminator is greater than the maximum allowed size, or the localeId is not well-formed, the error code is U_ILLEGAL_ARGUMENT_ERROR.
Returns:
The actual buffer size needed for the minimized locale. If it's greater than minimizedLocaleIDCapacity, the returned ID will be truncated. On error, the return value is -1. ICU 4.0

Definition at line 1241 of file loclikely.cpp.

References ULOC_FULLNAME_CAPACITY.

{
    char localeBuffer[ULOC_FULLNAME_CAPACITY];

    if (!do_canonicalize(
        localeID,
        localeBuffer,
        sizeof(localeBuffer),
        err)) {
        return -1;
    }
    else {
        return _uloc_minimizeSubtags(
                    localeBuffer,
                    minimizedLocaleID,
                    minimizedLocaleIDCapacity,
                    err);
    }    
}


Generated by  Doxygen 1.6.0   Back to index