当前位置: 首页>>代码示例>>C++>>正文


C++ Collator::setAttribute方法代码示例

本文整理汇总了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;
}
开发者ID:bdacode,项目名称:ArangoDB,代码行数:51,代码来源:Utf8Helper.cpp

示例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;
}
开发者ID:Acorld,项目名称:WinObjC-Heading,代码行数:27,代码来源:regcoll.cpp

示例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;
}
开发者ID:MIPS,项目名称:external-icu,代码行数:32,代码来源:regcoll.cpp


注:本文中的Collator::setAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。