Logo Search packages:      
Sourcecode: icu version File versions

Collator *U_EXPORT2 Collator::createInstance ( const Locale loc,
UErrorCode err 
) [static, inherited]

Gets the table-based collation object for the desired locale. The resource of the desired locale will be loaded by ResourceLoader. Locale::ENGLISH is the base collation table and all other languages are built on top of it with additional language-specific modifications. The UErrorCode& err parameter is used to return status information to the user. To check whether the construction succeeded or not, you should check the value of U_SUCCESS(err). If you wish more detailed information, you can check for informational error results which still indicate success. U_USING_FALLBACK_ERROR indicates that a fall back locale was used. For example, 'de_CH' was requested, but nothing was found there, so 'de' was used. U_USING_DEFAULT_ERROR indicates that the default locale data was used; neither the requested locale nor any of its fall back locales could be found. The caller owns the returned object and is responsible for deleting it.

locThe locale ID for which to open a collator.
errthe error code status.
the created table-based collation object based on the desired locale.
See also:
ResourceLoader ICU 2.2

Definition at line 311 of file coll.cpp.

References ICULocaleService::get(), Locale::getName(), Collator::setLocales(), and U_FAILURE.

    if (U_FAILURE(status)) 
        return 0;
    if (hasService()) {
        Locale actualLoc;
        Collator *result =
            (Collator*)gService->get(desiredLocale, &actualLoc, status);
        // Ugly Hack Alert! If the returned locale is empty (not root,
        // but empty -- getName() == "") then that means the service
        // returned a default object, not a "real" service object.  In
        // that case, the locale metadata (valid & actual) is setup
        // correctly already, and we don't want to overwrite it. (TODO
        // remove in 3.0) [aliu]
        if (*actualLoc.getName() != 0) {
            result->setLocales(desiredLocale, actualLoc, actualLoc);
        return result;
    return makeInstance(desiredLocale, status);

Here is the call graph for this function:

Generated by  Doxygen 1.6.0   Back to index