mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-21 04:29:31 +00:00
ICU-96 implement Collator::createInstance(...version...)
X-SVN-Rev: 4058
This commit is contained in:
parent
293d8eb7c4
commit
1096a2a2e7
2 changed files with 41 additions and 0 deletions
|
@ -88,6 +88,25 @@ Collator* Collator::createInstance(const Locale& desiredLocale,
|
|||
return collation;
|
||||
}
|
||||
|
||||
Collator *
|
||||
Collator::createInstance(const Locale &loc,
|
||||
UVersionInfo version,
|
||||
UErrorCode &status) {
|
||||
Collator *collator;
|
||||
UVersionInfo info;
|
||||
|
||||
collator=new RuleBasedCollator(loc, status);
|
||||
if(U_SUCCESS(status)) {
|
||||
collator->getVersion(info);
|
||||
if(0!=uprv_memcmp(version, info, sizeof(UVersionInfo))) {
|
||||
delete collator;
|
||||
status=U_MISSING_RESOURCE_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return collator;
|
||||
}
|
||||
|
||||
UBool Collator::equals(const UnicodeString& source,
|
||||
const UnicodeString& target) const
|
||||
{
|
||||
|
|
|
@ -275,6 +275,28 @@ public:
|
|||
*/
|
||||
static Collator* createInstance(const Locale& loc, UErrorCode& err);
|
||||
|
||||
/**
|
||||
* Create a Collator with a specific version.
|
||||
* This is the same as createInstance(loc, err) except that getVersion() of
|
||||
* the returned object is guaranteed to be the same as the version
|
||||
* parameter.
|
||||
* This is designed to be used to open the same collator for a given
|
||||
* locale even when ICU is updated.
|
||||
* The same locale and version guarantees the same sort keys and
|
||||
* comparison results.
|
||||
*
|
||||
* @param loc The locale ID for which to open a collator.
|
||||
* @param version The requested collator version.
|
||||
* @param err A reference to a UErrorCode,
|
||||
* must not indicate a failure before calling this function.
|
||||
* @return A pointer to a Collator, or 0 if an error occurred
|
||||
* or a collator with the requested version is not available.
|
||||
*
|
||||
* @see getVersion
|
||||
* @draft ICU 1.8
|
||||
*/
|
||||
static Collator *createInstance(const Locale &loc, UVersionInfo version, UErrorCode &err);
|
||||
|
||||
/**
|
||||
* The comparison function compares the character data stored in two
|
||||
* different strings. Returns information about whether a string is less
|
||||
|
|
Loading…
Add table
Reference in a new issue