本文整理汇总了C++中Collator::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ Collator::setAttribute方法的具体用法?C++ Collator::setAttribute怎么用?C++ Collator::setAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collator
的用法示例。
在下文中一共展示了Collator::setAttribute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LOG_ERROR
void Utf8Helper::setCollatorLanguage (const string& lang) {
UErrorCode status = U_ZERO_ERROR;
if (_coll) {
ULocDataLocaleType type = ULOC_ACTUAL_LOCALE;
const Locale& locale = _coll->getLocale(type, status);
if(U_FAILURE(status)) {
LOG_ERROR("error in Collator::getLocale(...): %s", u_errorName(status));
return;
}
if (lang == locale.getName()) {
return;
}
}
Collator* coll;
if (lang == "") {
// get default collator for empty language
coll = Collator::createInstance(status);
}
else {
Locale locale(lang.c_str());
coll = Collator::createInstance(locale, status);
}
if(U_FAILURE(status)) {
LOG_ERROR("error in Collator::createInstance(): %s", u_errorName(status));
if (coll) {
delete coll;
}
return;
}
// set the default attributes for sorting:
coll->setAttribute(UCOL_CASE_FIRST, UCOL_UPPER_FIRST, status); // A < a
coll->setAttribute(UCOL_NORMALIZATION_MODE, UCOL_OFF, status); // no normalization
coll->setAttribute(UCOL_STRENGTH, UCOL_IDENTICAL, status); // UCOL_IDENTICAL, UCOL_PRIMARY, UCOL_SECONDARY, UCOL_TERTIARY
if(U_FAILURE(status)) {
LOG_ERROR("error in Collator::setAttribute(...): %s", u_errorName(status));
delete coll;
return;
}
if (_coll) {
delete _coll;
}
_coll = coll;
}
示例2: el_GR
// @bug 4095316
//
void CollationRegressionTest::Test4095316(/* char* par */)
{
UErrorCode status = U_ZERO_ERROR;
Locale el_GR("el", "GR");
Collator *c = Collator::createInstance(el_GR, status);
if (c == NULL || U_FAILURE(status))
{
errln("Failed to create collator for el_GR locale");
delete c;
return;
}
// These now have tertiary differences in UCA
//c->setStrength(Collator::TERTIARY);
c->setAttribute(UCOL_STRENGTH, UCOL_SECONDARY, status);
static const UChar tests[][CollationRegressionTest::MAX_TOKEN_LEN] =
{
{0x03D4, 0}, {0x3d, 0}, {0x03AB, 0}
};
compareArray(*c, tests, ARRAY_LENGTH(tests));
delete c;
}
示例3: el
// @bug 4092260
//
// Mu/micro conflict
// Micro symbol and greek lowercase letter Mu should sort identically
//
void CollationRegressionTest::Test4092260(/* char* par */)
{
UErrorCode status = U_ZERO_ERROR;
Locale el("el", "");
Collator *c = NULL;
c = Collator::createInstance(el, status);
if (c == NULL || U_FAILURE(status))
{
errln("Failed to create collator for el locale.");
delete c;
return;
}
// These now have tertiary differences in UCA
c->setAttribute(UCOL_STRENGTH, UCOL_SECONDARY, status);
static const UChar tests[][CollationRegressionTest::MAX_TOKEN_LEN] =
{
{0x00B5, 0}, {0x3d, 0}, {0x03BC, 0}
};
compareArray(*c, tests, UPRV_LENGTHOF(tests));
delete c;
}