2014-10-05 67 views
2

我正在编写代码,在数据库中创建索引。随着ICU库我的工作流程是:boost :: locale icu sortKey

  • 字符串中的用户区域设置 - >
    转换为UTF8 - >
    正常化UTF8 - >
    呼叫ICU ucol_getSortKey以获取建设指标排序的关键。

现在我切换到Boost Locale。可以像ICU一样提升区域设置构建排序键?或者我应该直接拨打ICU?

回答

1

看起来这是升压地点曾被称作collate_impl::do_[basic_]transform()

std::vector<uint8_t> do_basic_transform(level_type level,CharType const *b,CharType const *e) const 
{ 
    icu::UnicodeString str=cvt_.icu(b,e); 
    std::vector<uint8_t> tmp; 
    tmp.resize(str.length()); 
    icu::Collator *collate = get_collator(level); 
    int len = collate->getSortKey(str,&tmp[0],tmp.size()); 
    if(len > int(tmp.size())) { 
     tmp.resize(len); 
     collate->getSortKey(str,&tmp[0],tmp.size()); 
    } 
    else 
     tmp.resize(len); 
    return tmp; 
} 

std::basic_string<CharType> do_transform(level_type level,CharType const *b,CharType const *e) const 
{ 
    std::vector<uint8_t> tmp = do_basic_transform(level,b,e); 
    return std::basic_string<CharType>(tmp.begin(),tmp.end()); 
} 

出于性能方面,它看起来像你想打电话do_basic_compare