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

U_STABLE int32_t U_EXPORT2 uloc_getParent ( const char *  localeID,
char *  parent,
int32_t  parentCapacity,
UErrorCode err 

Truncate the locale ID string to get the parent locale ID. Copies the part of the string before the last underscore. The parent locale ID will be an empty string if there is no underscore, or if there is only one underscore at localeID[0].

localeIDInput locale ID string.
parentOutput string buffer for the parent locale ID.
parentCapacitySize of the output buffer.
errA UErrorCode value.
The length of the parent locale ID. ICU 2.0

Definition at line 1800 of file uloc.c.

References NULL, and U_FAILURE.

    const char *lastUnderscore;
    int32_t i;
    if (U_FAILURE(*err))
        return 0;
    if (localeID == NULL)
        localeID = uloc_getDefault();

    lastUnderscore=uprv_strrchr(localeID, '_');
    if(lastUnderscore!=NULL) {
    } else {

    if(i>0 && parent != localeID) {
        uprv_memcpy(parent, localeID, uprv_min(i, parentCapacity));
    return u_terminateChars(parent, parentCapacity, i, err);

Generated by  Doxygen 1.6.0   Back to index